Date: Thu, 28 Aug 1997 12:21:08 +0300 (IDT) From: Eli Zaretskii To: IBEC23 AT cc DOT uab DOT es cc: djgpp AT delorie DOT com Subject: Re: How coould I know if two files are the same? In-Reply-To: <01IMY1B3EI4I00G6WZ@cc.uab.es> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk 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.