独立于平台模拟目录树

发布于 2024-09-28 14:01:54 字数 363 浏览 1 评论 0原文

我在一个应用程序中使用 Qt 和 Ruby,我必须操作一些目录并重命名/移动文件。然而,在实际操作之前,我需要显示“预览”,即更改的模拟。我在 OS X 和 Linux 上所做的是在可写的 tmp 空间中收集 mkdirtouch 命令,以构建我所说的“目录树”,并提供该命令到 Qt 的 QFileSystemModel 小部件和 QTreeView,我会得到预期的结果。

但是,我无法在 Windows 上执行此操作,因为我没有找到 touch 的本机对应项,因此无法显示文件。我想到的一个建议是在内存中创建目录树,但随后我无法再将其提供给 QFileSystemModel 。

我该怎么做?

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.

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倾听心声的旋律 2024-10-05 14:01:54

Windows 附带了一个名为 fsutil 的工具,可用于创建类似于 Unix touch 命令的虚拟文件:

fsutil file createnew PathName length

我不确定 fsutil 是否默认存在在 Windows 家庭版中,但至少在 XP 到 Windows 7 的专业版中是这样。

请参阅 fsutil 的完整文档

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文