简体   繁体   English

如何使用KDE / Qt4查询文件的包含分区?

[英]How to query the containing partition of a file with KDE/Qt4?

I'm using KDE, and I'm toying with the idea of hacking the code for Dolphin File Manager (and potentially Konqueror if necessary) to get context-sensitive drag and drop behaviour (ie files are moved within the same partition, or copied if they're moved across partitions or the source is read only). 我正在使用KDE,并且想弄乱Dolphin File Manager的代码(如有必要,可能还有Konqueror),以获得上下文相关的拖放行为(即文件在同一分区内移动或复制) (如果它们跨分区移动或源是只读的)。

To do this, I think I'd need to find out the containing partition of the source and destination (easy enough on Windows using the drive letter, but on Linux, as mount points can be almost anywhere, it can't be reliably derived from the file path), and compare them. 为此,我认为我需要找出源和目标的包含分区(在Windows中使用驱动器号非常容易,但是在Linux上,由于挂载点几乎可以在任何地方,因此无法可靠地导出它从文件路径),并进行比较。 Does anyone know how I can find out the partition that contains a given file? 有谁知道我如何找出包含给定文件的分区?

It must be possible - I know Nautilus provides this sort of behaviour, but I'm not familiar enough with GTK to track down the appropriate section in the source code to see how its done... 可能是有可能的-我知道Nautilus提供了这种行为,但是我对GTK不够熟悉,无法在源代码中找到适当的部分以查看其工作方式...

Qt doesn't provide API for this. Qt没有为此提供API。 For POSIX, have a look at stat . 对于POSIX,请查看stat

For KDE, you can use KIO::stat() to get mostly the same info as POSIX' stat function but asynchronously. 对于KDE,您可以使用KIO::stat()来获取与POSIX stat函数几乎相同的信息,但是是异步的。
The device id should be in the field UDS_DEVICE_ID of the result. 设备ID应该在结果的字段UDS_DEVICE_ID中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM