Mail Archives: djgpp/1997/08/28/05:24:23
On Wed, 27 Aug 1997 IBEC23 AT cc DOT uab DOT es wrote:
> When a network disk drive X:\ is the same as M:\FOLDER,
> my program "believes" that
> X:\FILENAME.TXT
> is different from
> M:\FOLDER\FILENAME.TXT
> but it is the same file.
[snip]
> Is there some way to detect it using DJGPP?
Yes, use the library function `_truename'. It should return the
same canonical string for each of these cases.
Another way would be to call `stat' on both files and compare the
st_dev and st_ino members of struct stat: if both of them are
identical, the two names refer to the same file.
The second way is more portable (since `stat' is a POSIX function,
whereas `_truename' was invented for DJGPP), at least if your program
will need to run on Unix (DOS and MS-Windows compilers usually return
zero st_ino for all files, since Microsoft filesystems don't have
inodes). The call to `stat' is also much more expensive (in DJGPP),
so if you need to compare hundreds of files, `_truename' would be much
faster.
If any of these two methods doesn't work for you, please post the
details here.
- Raw text -