[PATCH] GetFileAttributesEx not present on Win95
Ranjit Mathew
rmathew@hotmail.com
Sun Oct 20 12:21:00 GMT 2002
Adam Megacz wrote:
> IIRC, CreateFile will fail if another process has locked the file
> (which most Win32 apps do, since it's the default). Could we detect
Yes indeed! I verified this on my Win98 box where even a simple
open operation on a file by one process locks it out for another.
No such problem was there for GetFileAttributesEx( ) though.
Here's a simpler patch that uses FindFirstFile( ) instead:
-------------------------------- 8< -----------------------------------
--- natFileWin32.cc Sun Oct 20 22:59:12 2002
+++ natFileWin32.cc Mon Oct 21 00:22:18 2002
@@ -84,7 +84,10 @@
JvAssert (query == MODIFIED || query == LENGTH);
- WIN32_FILE_ATTRIBUTE_DATA info;
- if (! GetFileAttributesEx(buf, GetFileExInfoStandard, &info))
+ WIN32_FIND_DATA info;
+ HANDLE sHandle;
+ if ( ( sHandle = FindFirstFile( buf, &info)) == INVALID_HANDLE_VALUE)
return 0;
+
+ FindClose( sHandle);
if (query == LENGTH)
-------------------------------- 8< -----------------------------------
At least according to my tests, FindFirstFile( ) does not suffer
from being locked out when another process is accessing the file
in question.
> the OS version and use the latter only if it's Win95?
The EXE generated would still refer to GetFileAttributesEx( ) from
KERNEL32.DLL and the program loader on Win95 would still fail with a
missing symbol error, IMO.
> Win32 has a _stat()? I can't find it in Win32.hlp...
MSVCRT has it - that probably also means that it is ruled out
if it is to be built with CygWin.
Sincerely Yours,
Ranjit.
--
Ranjit Mathew Email: rmathew AT hotmail DOT com
Bangalore,
INDIA. Web: http://ranjitmathew.tripod.com/
More information about the Java-patches
mailing list