Since you know you’re on Windows, you can call GetFullPathName on two dirs and compare results. It is available since XP and present in kernel32
DWORD WINAPI GetFullPathName( _In_ LPCTSTR lpFileName, _In_ DWORD nBufferLength, _Out_ LPTSTR lpBuffer, _Out_ LPTSTR *lpFilePart ); See https://msdn.microsoft.com/en-us/library/windows/desktop/aa364963(v=vs.85).aspx From: [email protected] [mailto:[email protected]] On Behalf Of avih Sent: samedi 7 novembre 2015 16:11 To: [email protected] Subject: Re: [Tinycc-devel] "mormalize_inc_dirs" To check whether or not two dirs are the same without stat, one could cdhir to each dir (from the base dir) and then getcwd. As far as I know this always returns the canonicalized path, therefore makes the two path comparable. This can work on Windows too. But let's backtrace a bit: As far as I can tell, the sequence of events was as follows: 1. seyko commits "mormalize_inc_dirs" 2. I said (and now adding: on windows 8.1 with msys2 and gcc 5.2.0): Prior to this commit, when building tcc itself (configure and make), after successfully building the tcc executable (on windows for windows), it starts building libtcc1.a using the just-compiled tcc.exe, and succeeded. This process now fails for me (missing stddef.h for libtcc1.a) ... 3. Roy Tam said: BTW this commit breaks tcc compiling itself afterwards. WinXP SP3 32bit, MinGW(tcc self compilation test) Using the compiled tcc to recompile tcc itself fails with windows.h not found. I have to reverting this commit to recover. ---------- So far, from these two comment, it's apparent that the newly built windows tcc executable does not resolve dirs the same as it used to. It's unclear whether other platforms are affected. ---------- 4. seyko responds to Toy Tam: Anyone know solution for stat? From Google: "stat" not working on Windows XP using v14_xp platform ... stat() does not work for me on Cygwin/Windows - C / C++ Portable way to check if directory exists? 5. (now) A discussion goes on how to compare dirs on XP. So, do we know for a fact that this is the actual problem? I.e. that the current dir resolution failure is due to missing code which needs to check if two dirs are the same? If such required dir comparison was missing from the code, then I'd expect that other platforms are affected as well. But as far as I can tell there wasn't indication for that so far. Though it's possible that other platforms are affected, but the issue doesn't affect the tcc build process on those platforms, but it does on windows. However, how come the old code did not need to compare such two dirs, and still worked correctly? If the old code was working correctly without needing to compare two actual dirs, despite it not being "n[m]ormalized", maybe it's still the better solution because it depends less on features which are harder to use reliably on different platforms? On Saturday, November 7, 2015 3:59 PM, Edmund Grimley Evans <[email protected]> wrote: > Hum! You can: > fopen("dir-to-test/__deleteme__", "w"); > If it succeeds, dir-to-test exists then call fclose and > remove("dir-to-test/__deleteme__"). As I understand it, the problem to be solved is not determining whether a directory exists, but determining whether two directories are the same (even though the paths might look quite different). You can do that under POSIX by comparing st_dev and st_ino. I suppose you could check that neither PATH1/RANDOM_NAME nor PATH2/RANDOM_NAME exists, then create one of them and see if the other now exists. But in most cases the directories are not writable! Does GCC have an alternative implementation for systems without stat? Edmund _______________________________________________ Tinycc-devel mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/tinycc-devel
_______________________________________________ Tinycc-devel mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/tinycc-devel
