Creating dynamic Network Shortcuts
-
wrote on 28 Jan 2019, 17:39 last edited by aha_1980
Hello,
we use a DiskStation in Network. If we move some Files or Folders the Windows Shortcuts (.lnk) are getting broken and there is no System-automatic way to correct this.
Now i want to write a small Programm that set the new link´s if there are some changes in the File-system.I think about to stores the Link- and Targetpath in a File and looking for changes with QFileSystemModel (signal: fileRenamed).
But i can´t find a way to watch out if a file is moved to an other Folder. In the QFileSystemWatcher Class, there is only a way to check out if the File is removed from the current Folder.Can someone help me to get this working? Or did someone have an better idea to solve this Problem?
My brain is broken :D
Thank you from Germany -
Hello,
we use a DiskStation in Network. If we move some Files or Folders the Windows Shortcuts (.lnk) are getting broken and there is no System-automatic way to correct this.
Now i want to write a small Programm that set the new link´s if there are some changes in the File-system.I think about to stores the Link- and Targetpath in a File and looking for changes with QFileSystemModel (signal: fileRenamed).
But i can´t find a way to watch out if a file is moved to an other Folder. In the QFileSystemWatcher Class, there is only a way to check out if the File is removed from the current Folder.Can someone help me to get this working? Or did someone have an better idea to solve this Problem?
My brain is broken :D
Thank you from Germany@o0TheRat0o
i believe there is no Qt-way of achieving this. I think you will have to use native API (if ther is any at all).But what you can try is to add a QFileSystemWatcher on the root drive? In case the QFileSystemWatcher class triggers changes also for files in sub-folders? I dont know if thats the case.
-
wrote on 28 Jan 2019, 19:03 last edited by
@raven-worx
Yes i have think about that way, too.
But in this case it has to be a recursively implementing and i am a bit worried about the efficiency. Because it have to work with changes and renaming.
I already think about to get the Path´s of the open Explorer Windows. But i don´t know how to implement this.
If i could get this Path´s, i could use it to realetime watching if there some movements between this Folders. -
@raven-worx
Yes i have think about that way, too.
But in this case it has to be a recursively implementing and i am a bit worried about the efficiency. Because it have to work with changes and renaming.
I already think about to get the Path´s of the open Explorer Windows. But i don´t know how to implement this.
If i could get this Path´s, i could use it to realetime watching if there some movements between this Folders.@o0TheRat0o said in Creating dynaimc Network Shortcuts:
I already think about to get the Path´s of the open Explorer Windows. But i don´t know how to implement this.
files can be moved also wihtout the explorer window
Anyway, QFileSystemWatcher has only a limited amount of paths to watch (this is OS dependant). So recursing isn't an option anyway. A watched path for each root drive should be enough, in case it works as i said.
-
wrote on 28 Jan 2019, 22:29 last edited by
@raven-worx said in Creating dynamic Network Shortcuts:
files can be moved also wihtout the explorer window
That´s right, but in most simple File changes, the Explorer is used.
Anyway, QFileSystemWatcher has only a limited amount of paths to watch (this is OS dependant). So recursing isn't an option anyway. A watched path for each root drive should be enough, in case it works as i said.
For testing i write the Code below. But it´s only working in the direkt E:/ path. Not in Subfolders. And it seems there is no Way to check Subfolders without ->addPaths() and the risk of limited amount of paths?
watcher = new QFileSystemWatcher(this); watcher->addPath("E:/"); connect( watcher, SIGNAL(directoryChanged(const QString &)), this, SLOT(directoryChanged(const QString &)) ); connect( watcher, SIGNAL(fileChanged(const QString &)), this, SLOT(fileChanged(const QString &)) );
hm.... there sould be a solution....
1/5