This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: [PATCH] GetFileAttributesEx not present on Win95
- From: Ranjit Mathew <rmathew at hotmail dot com>
- To: java-patches at gcc dot gnu dot org
- Cc: Fernando Lozano <fernando at lozano dot eti dot br>
- Date: Mon, 21 Oct 2002 00:42:08 +0530
- Subject: Re: [PATCH] GetFileAttributesEx not present on Win95
- References: <3DB01876.5090301@hotmail.com> <86wuofjp7t.fsf@nowhere.com>
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/