0


I create an app that takes a copy of a Directory on C drive windows system to another folder when I work with windows system I give my app admin using this way here.
I use this code to copy the folder with all its content. this function.

    void MainWindow::copyPath(QString src, QString dst)
{
    QDir dir(src);
    if (! dir.exists())
        return;

    foreach (QString d, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) {
        QString dst_path = dst + QDir::separator() + d;
        dir.mkpath(dst_path);
        copyPath(src+ QDir::separator() + d, dst_path);
    }

    foreach (QString f, dir.entryList(QDir::Files)) {
        QFile::copy(src + QDir::separator() + f, dst + QDir::separator() + f);
    }
}

and in the button

copyPath("C:/Windows/System32/spp/store", "D:/copyfolder");

when I test on another folder on D drive it worked so what I can do so that I make my qt app copy the folder from the C drive.
when I give it this path C:/Windows/System32/spp/ it copies only one folder which is C:/Windows/System32/spp/tokens and the other folders not copied, when I give it the path C:/Windows/System32/spp/store, it can't path this condition

QDir dir(src);
    if (! dir.exists())
        return;

it can't recognize directory. so please if I can do this in C# for example or any other way no problem please provide any information, as I tried with C# and it did not work too.

Keyur Ramoliya
  • 1,900
  • 2
  • 16
  • 17
user7179690
  • 1,051
  • 3
  • 17
  • 40
  • Can you copy the files in Explorer? If not there's probably a lock on one of the files, for example it's open in another application. – MrEricSir Jul 09 '18 at 06:05
  • Thank you for your reply, Yes i tried to copy it manually it copied with no problem at all – user7179690 Jul 09 '18 at 06:07
  • 1
    Which compiler are you using? If it's 32-bit, then its likely that your path-access is masked to [...]\SysWOW64\[...] when accessing [...]\system32\[...]. – markus-nm Jul 09 '18 at 11:46
  • yes iam using 32 as i use Mingw it have only 32 in QT – user7179690 Jul 09 '18 at 12:56

1 Answers1

0

Hokay, @markus has spotted the rabbit so let's work it up into an answer.

64 bit Windows has something called the File System Redirector, which fools 32 bit apps into thinking they are looking at (for example) C:\WINDOWS\SYSTEM32 when in fact they're not. Details behind that link.

However, you can turn it off. In terms of raw Win32 calls, you can do:

VOID *oldValue;
BOOL ok = Wow64DisableWow64FsRedirection (&oldValue);
// ...
ok = Wow64RevertWow64FsRedirection (oldValue);

It's hard to imagine why these calls would ever fail.

There is also:

BOOLEAN Wow64EnableWow64FsRedirection (BOOLEAN Wow64FsEnableRedirection);

which lets you turn it on (for masochists only) or off unconditionally.

There doesn't seem to be a call to find out if redirection is currently enabled. I guess you can do is to assume that it is enabled on program startup (which it will be) and then track any changes you make yourself.

Paul Sanders
  • 24,133
  • 4
  • 26
  • 48