This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Bug in natFileDescriptorWin32.cc ?


Hi,

First of all, please cc me because I'm not subscribed to this list.

I tried to build a native win32 Freenet binary using gcj and I think I found a problem. When Freenet is started for the first time, the cache file is created. But, using the gcj binary, cache was created (ie truncated at 0) every 5 seconds. So I started to look into gcj and compared 'open' functions of natFileDescriptorPosix.cc and natFileDescriptorWin32.cc. Here's what I understood (I'm not really familiar with posix functions) and the problem I saw in the win32 port:

When jflags are READ & WRITE:
- Create the file if it does not exist, otherwise, open it.
* Problem: If not in APPEND mode, the file is created.
When jflags are READ:
- Open the file and return an error if it does not exist
When jflags are WRITE:
- When using APPEND, the file is created if it does not exist, otherwise it is opened.
- When using EXCL, the file is created if it does not exist and an error is returned if it exists.
* Problem: File is created if it doesn't exist.
- Otherwise, the file is created if it does not exist and truncated to 0 if it exists.

Since I'm not experienced enough with all this c++ stuff, I send you this patch only as a suggestion.

I hope it will help you
Nels

Patch:
======

--- natFileDescriptorWin32.cc.old 2002-06-03 10:00:22.000000000 +0200
+++ natFileDescriptorWin32.cc 2002-06-03 10:12:36.000000000 +0200
@@ -98,10 +98,7 @@
{
access = GENERIC_READ | GENERIC_WRITE;
share = 0;
- if (jflags & APPEND)
create = OPEN_ALWAYS;
- else
- create = CREATE_ALWAYS;
}
else if(jflags & READ)
access = GENERIC_READ;
@@ -111,6 +108,8 @@
share = 0;
if (jflags & APPEND)
create = OPEN_ALWAYS;
+ else if (jflags & EXCL)
+ create = CREATE_NEW
else
create = CREATE_ALWAYS;
}



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]