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 libgcj/11575] [win32] Problem with RandomAccessFile - patch


 Hello

This patch, based on the fix suggested, by the bug reporter fixes
PR libgcj/11575 and brings the behaviour of open on win32 closer to
the posix version. It also provides support for EXCL flag.

For a reference on what the native CreateFile flags do see,
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/createfile.asp


Tested on i386-pc-mingw32/mainline

Changelog

	2003-08-07  Danny Smith <dannysmith@users.sourceforge.net>

	PR libgcj/11575 
	* java/io/natFileDescriptorWin32.cc (open): Set create
	flag to OPEN_AWAYS when READ & WRITE regardless of APPEND flag.
	Honor EXCL when openning with WRITE flag. 

Index: java/io/natFileDescriptorWin32.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/natFileDescriptorWin32.cc,v
retrieving revision 1.13
diff -c -3 -p -r1.13 natFileDescriptorWin32.cc
*** java/io/natFileDescriptorWin32.cc	13 May 2003 09:13:31 -0000	1.13
--- java/io/natFileDescriptorWin32.cc	6 Aug 2003 10:01:18 -0000
*************** java::io::FileDescriptor::open (jstring 
*** 97,116 ****
    if ((jflags & READ) && (jflags & WRITE))
      {
        access = GENERIC_READ | GENERIC_WRITE;
!       if (jflags & APPEND)
! 	create = OPEN_ALWAYS;
        else
! 	create = CREATE_ALWAYS;
      }
!   else if(jflags & READ)
!     access = GENERIC_READ;
!   else
      {
        access = GENERIC_WRITE;
!       if (jflags & APPEND)
  	create = OPEN_ALWAYS;
        else
!         create = CREATE_ALWAYS;
      }
  
    handle = CreateFile(buf, access, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, create, 0, NULL);
--- 97,121 ----
    if ((jflags & READ) && (jflags & WRITE))
      {
        access = GENERIC_READ | GENERIC_WRITE;
!       if (jflags & EXCL)
! 	create = CREATE_NEW; // this will raise error if file exists.
        else
! 	create = OPEN_ALWAYS; // equivalent to O_CREAT
      }
!   else if (jflags & READ)
      {
+       access = GENERIC_READ;
+       create = OPEN_EXISTING; // ignore EXCL
+     }
+   else
+     { 
        access = GENERIC_WRITE;
!       if (jflags & EXCL)
! 	create = CREATE_NEW;
!       else if (jflags & APPEND)
  	create = OPEN_ALWAYS;
        else
! 	create = CREATE_ALWAYS;
      }
  
    handle = CreateFile(buf, access, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, create, 0, NULL);

http://personals.yahoo.com.au - Yahoo! Personals
-  New people, new possibilities! Try Yahoo! Personals, FREE for a limited period!


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