Simulating a directory tree platform-independently
I am using Qt and Ruby in an application where I have to manipulate some directories and rename/move files. However, prior to the actual manipulation I need to show a "preview", ie, simulation of the changes. What I've done on OS X and Linux is a collection of mkdir
and touch
commands, in a writable tmp space, to build my said "directory tree", fed that to Qt's QFileSystemModel
widget and QTreeView
, and I'd get my expected results开发者_如何学Go.
However, I can not do that on Windows, because I have found no native counterpart to touch
and thus I could not show the files. One suggestion that came to mind is to create my directory tree in memory, but then I can not feed it to QFileSystemModel
anymore.
How can I do this?
Windows comes with a tool called fsutil, which can be used to create dummy files similar to Unix touch command:
fsutil file createnew PathName length
I am not sure if fsutil exist per default on the Home editions of Windows, but at least it is in the professional versions of XP through Windows 7.
See the full documentation for fsutil.
精彩评论