Detect if two files are in the same physical disk

Hi all:

I need to know if, given two paths to local files, they are in the same partition/physical disk or not (to implement “move between the same disk/copy from one disk to another”). Does GLib/Gio have a way for doing this?


See the documentation for G_FILE_ATTRIBUTE_ID_FILESYSTEM.

#define G_FILE_ATTRIBUTE_ID_FILESYSTEM "id::filesystem"         /* string */

A key in the “id” namespace for getting the file system identifier. Corresponding GFileAttributeType is G_FILE_ATTRIBUTE_TYPE_STRING. An example use would be during drag and drop to see if the source and target are on the same filesystem (default to move) or not (default to copy).

1 Like

Thanks! In fact, it is precisely to implement Drag’n’Drop.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.