Hi
Is there any standard way to determine two path points to same storage Drive/Disk/Share location?
In linux I found this:
var
sInfo1, sInfo2: TStatfs;
begin
if (fpStatFS(UTF8ToSys(PathA), @sInfo1) <> - 1) and (fpStatFS(UTF8ToSys(PathB), @sInfo2) <> - 1) then
begin
Result := (sInfo1.fsid[0] = sInfo2.fsid[0]) and (sInfo1.fsid[1] = sInfo2.fsid[1]);
end
else
Exit(False);
end
Its works for Paths like these:
/home/Pascal/A <-- /dev/sda1/Pascal/A
/home/Pascal/B <-- /dev/sdb3/ Mounted here
Also I dont know how to check if these are sym/hard links!
Note for f_fsid:The general idea is that
f_fsid contains some random stuff such that
the pair (f_fsid,ino) uniquely determines a file. Some operating
systems use (a variation on) the device number, or the device number
combined with the filesystem type. Several operating systems
restrict giving out the f_fsid field to the superuser only (and zero
it for unprivileged users), because this field is used in the
filehandle of the filesystem when NFS-exported, and giving it out is
a security concern.
Under some operating systems, the fsid can be used as the second
argument to the sysfs(2) system call.
Under Ubuntu 16.04 64-bit it seems work correctly for none linked folders!
But on windows even for
D:\A <-- Local folder on D:
D:\B <-- Next partition mounted hre
Or even mapped Drive
\\192.168.1.152\SharedFolder <-- Just a shared folder
E:\ <-- \\192.168.1.152\SharedFolder Mapped here on E:\
On windows I found something like
GetFileInformationByHandle :
You can compare the VolumeSerialNumber and FileIndex members returned in the BY_HANDLE_FILE_INFORMATION structure to determine if two paths map to the same target; for example, you can compare two file paths and determine if they map to the same directory. [From MSDN]
Until last night I have an stupid idea to compare Size and Available free space to detect it!
But tow Hard disks with same size and partitioned as a just one partition presents same Size,
Or tow path that correctly located under same Partition and while we have heavy changes on it reports different Available remaining space even !
However I dont test it(Compare of Size and remaining space) of paths!