diff options
author | Mohan Embar <gnustuff@thisiscool.com> | 2003-08-29 04:21:01 +0000 |
---|---|---|
committer | Mohan Embar <membar@gcc.gnu.org> | 2003-08-29 04:21:01 +0000 |
commit | 5c14415811b48f1b486be91ea41661381f08a3fe (patch) | |
tree | 236d99541a3b4c358a6a326abd76276ce8557c33 /libjava/java/io | |
parent | a1d6cdc2d7a48f9b584e2323b173176055adc53a (diff) | |
download | gcc-5c14415811b48f1b486be91ea41661381f08a3fe.zip gcc-5c14415811b48f1b486be91ea41661381f08a3fe.tar.gz gcc-5c14415811b48f1b486be91ea41661381f08a3fe.tar.bz2 |
win32.cc: fixed tab...
* win32.cc: fixed tab, indentation and whitespace
inconsistencies
removed jvm.h include
added includes java/lang/UnsupportedOperationException.h,
java/io/IOException.h, java/net/SocketException.h
(WSAEventWrapper): class implementation
(_Jv_WinStrError): implemented both overloads
(_Jv_ThrowIOException): implemented both overloads
(_Jv_ThrowSocketException): implemented both overloads
(_Jv_select): implemented
* include/win32.h: fixed tab, indentation and whitespace
inconsistencies
wrapped <windows.h> include with #define WIN32_LEAN_AND_MEAN
added jvm.h include
(WSAEventWrapper): added class declaration
(_Jv_WinStrError): added both overload declarations
(_Jv_ThrowIOException): added both overload declarations
(_Jv_ThrowSocketException): added both overload declarations
removed ENOTCONN, ECONNRESET and ENOPROTOOPT defines
(_Jv_select): added declaration
(_Jv_socket): removed
(_Jv_connect): removed
(_Jv_close): removed
(_Jv_bind): removed
(_Jv_accept): removed
(_Jv_listen): removed
(_Jv_write): removed
(_Jv_read): removed
* java/io/natFileDescriptorWin32.cc: fixed tab, indentation and
whitespace inconsistencies
replaced <windows.h> #include with <platform.h>
removed jvm.h include
(testCanUseGetHandleInfo): new function which tests whether Win32
GetHandleInformation() call can be used with console buffer handles
(only supported on >=WinNT 5.0)
(winerr): removed (superseded by _Jv_WinStrError in include/win32.h)
(valid): rewrote implementation using GetHandleInformation()
(sync): changed exception throwing to use error string and exception
helper methods declared in include/win32.h
(open): likewise
(write): likewise
(setLength): likewise
(close): likewise
(seek): likewise
(getFilePointer): likewise
(read): likewise
* java/io/natFileWin32.cc: fixed tab, indentation and
whitespace inconsistencies
replaced <windows.h> #include with <platform.h>
removed jvm.h include
(_access): use JV_TEMP_UTF_STRING
(_stat): likewise
(performMkDir): use JV_TEMP_UTF_STRING
(performRenameTo): likewise
(performDelete): likewise
(performCreate): likewise
(performSetReadOnly): likewise
(performSetLastModified): likewise
* java/lang/natWin32Process.cc: fixed tab, indentation and
whitespace inconsistencies
replaced <windows.h> #include with <platform.h>
removed includes gcj/cni.h, jvm.h
(new_string): removed
(startProcess): use JV_TEMP_UTF_STRING,
changed exception throwing to use error string and exception
helper methods declared in include/win32.h
* java/net/natInetAddressWin32.cc: fixed tab, indentation and
whitespace inconsistencies
replaced <windows.h> #include with <platform.h>
removed jvm.h include
removed DISABLE_JAVA_NET conditional code
removed POSIX conditional code not relevant to Win32
(aton): use JV_TEMP_UTF_STRING
removed POSIX conditional code not relevant to Win32
(lookup): likewise
(getLocalHostName): likewise
* java/net/natNetworkInterfaceWin32.cc: fixed tab, indentation and
whitespace inconsistencies
removed unnecessary windows.h, winsock.h and gcj/cni.h includes
removed DISABLE_JAVA_NET conditional code
removed POSIX conditional code not relevant to Win32
(winsock2GetRealNetworkInterfaces): new function to compute network
interfaces via Winsock2 API
(determineGetRealNetworkInterfacesFN): new function for returning
a function pointer to the function used to compute network interfaces.
(getRealNetworkInterfaces): implemented
* java/net/natPlainDatagramSocketImplWin32.cc: fixed tab, indentation and
whitespace inconsistencies
removed gcj/cni.h include
removed DISABLE_JAVA_NET conditional code
removed POSIX conditional code not relevant to Win32
changed net POSIXisms to Win32isms
replaced _Jv socket-related calls with their real Win32 equivalents
changed exception throwing to use error string and exception
helper methods declared in include/win32.h
(peekData): implemented timeout support
(receive): likewise
* java/net/natPlainSocketImplWin32.cc: fixed tab, indentation and
whitespace inconsistencies
removed gcj/cni.h and gcj/javaprims.h includes
removed DISABLE_JAVA_NET conditional code
removed POSIX conditional code not relevant to Win32
changed net POSIXisms to Win32isms
replaced _Jv socket-related calls with their real Win32
equivalents
changed exception throwing to use error string and exception
helper methods declared in include/win32.h
(throwConnectException): helper function for connect()
(connect): implemented timeout support
(accept): likewise
(doRead): new helper function common to both read() method overloads,
includes timeout support
(read): implemented both overloads in terms of doRead()
(available): implemented using ioctlsocket()
From-SVN: r70904
Diffstat (limited to 'libjava/java/io')
-rw-r--r-- | libjava/java/io/natFileDescriptorWin32.cc | 141 | ||||
-rw-r--r-- | libjava/java/io/natFileWin32.cc | 118 |
2 files changed, 116 insertions, 143 deletions
diff --git a/libjava/java/io/natFileDescriptorWin32.cc b/libjava/java/io/natFileDescriptorWin32.cc index 5066987..1891bf7 100644 --- a/libjava/java/io/natFileDescriptorWin32.cc +++ b/libjava/java/io/natFileDescriptorWin32.cc @@ -13,15 +13,13 @@ details. */ // need to change to use the windows asynchronous IO functions #include <config.h> +#include <platform.h> #include <stdio.h> #include <string.h> -#include <windows.h> #undef STRICT -#include <gcj/cni.h> -#include <jvm.h> #include <java/io/FileDescriptor.h> #include <java/io/SyncFailedException.h> #include <java/io/IOException.h> @@ -33,6 +31,16 @@ details. */ #include <java/lang/Thread.h> #include <java/io/FileNotFoundException.h> +static bool testCanUseGetHandleInfo() +{ + /* Test to see whether GetHandleInformation can be used + for console input or screen buffers. This is better + a kludgy OS version check. */ + DWORD dwFlags; + return GetHandleInformation (GetStdHandle (STD_INPUT_HANDLE), + &dwFlags) != 0; +} + // FIXME: casting a FILE (pointer) to a jint will not work on Win64 -- // we should be using gnu.gcj.RawData's. @@ -44,41 +52,32 @@ java::io::FileDescriptor::init(void) err = new java::io::FileDescriptor((jint)(GetStdHandle (STD_ERROR_HANDLE))); } -static char * -winerr (void) -{ - static LPVOID last = NULL; - LPVOID old = NULL; - - if (last) - old = last; - - FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR) &last, - 0, - NULL); - - if (old) - LocalFree (old); - - return (char *)last; -} - jboolean java::io::FileDescriptor::valid (void) { - BY_HANDLE_FILE_INFORMATION info; - return GetFileInformationByHandle ((HANDLE)fd, &info) != 0; + static bool bCanUseGetHandleInfo = testCanUseGetHandleInfo(); + if (bCanUseGetHandleInfo) + { + /* As with UNIX, a "file" descriptor can be one of + a gazillion possible underlying things like a pipe + or socket, so we can't get too fancy here. */ + DWORD dwFlags; + HANDLE h = (HANDLE) fd; + return GetHandleInformation (h, &dwFlags) != 0; + } + else + { + /* Can't use GetHandleInformation() for console handles on < WinNT 5. */ + return true; + } } void java::io::FileDescriptor::sync (void) { if (! FlushFileBuffers ((HANDLE)fd)) - throw new SyncFailedException (JvNewStringLatin1 (winerr ())); + { + DWORD dwErrorCode = GetLastError (); + throw new SyncFailedException (_Jv_WinStrError (dwErrorCode)); + } } jint @@ -87,10 +86,8 @@ java::io::FileDescriptor::open (jstring path, jint jflags) { HANDLE handle = NULL; DWORD access = 0; DWORD create = OPEN_EXISTING; - char buf[MAX_PATH] = ""; - - jsize total = JvGetStringUTFRegion(path, 0, path->length(), buf); - buf[total] = '\0'; + + JV_TEMP_UTF_STRING(cpath, path) JvAssert((jflags & READ) || (jflags & WRITE)); @@ -98,9 +95,9 @@ java::io::FileDescriptor::open (jstring path, jint jflags) { { access = GENERIC_READ | GENERIC_WRITE; if (jflags & EXCL) - create = CREATE_NEW; // this will raise error if file exists. + create = CREATE_NEW; // this will raise error if file exists. else - create = OPEN_ALWAYS; // equivalent to O_CREAT + create = OPEN_ALWAYS; // equivalent to O_CREAT } else if (jflags & READ) { @@ -111,20 +108,19 @@ java::io::FileDescriptor::open (jstring path, jint jflags) { { access = GENERIC_WRITE; if (jflags & EXCL) - create = CREATE_NEW; + create = CREATE_NEW; else if (jflags & APPEND) - create = OPEN_ALWAYS; + create = OPEN_ALWAYS; else - create = CREATE_ALWAYS; + create = CREATE_ALWAYS; } - handle = CreateFile(buf, access, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, create, 0, NULL); + handle = CreateFile(cpath, access, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, create, 0, NULL); if (handle == INVALID_HANDLE_VALUE) { - char msg[MAX_PATH + 1000]; - sprintf (msg, "%s: %s", buf, winerr ()); - throw new FileNotFoundException (JvNewStringLatin1 (msg)); + DWORD dwErrorCode = GetLastError (); + throw new FileNotFoundException (_Jv_WinStrError (cpath, dwErrorCode)); } // For APPEND mode, move the file pointer to the end of the file. @@ -132,7 +128,10 @@ java::io::FileDescriptor::open (jstring path, jint jflags) { { DWORD low = SetFilePointer (handle, 0, NULL, FILE_END); if ((low == 0xffffffff) && (GetLastError () != NO_ERROR)) - throw new FileNotFoundException (JvNewStringLatin1 (winerr ())); + { + DWORD dwErrorCode = GetLastError (); + throw new FileNotFoundException (_Jv_WinStrError (cpath, dwErrorCode)); + } } return (jint)handle; } @@ -149,13 +148,13 @@ java::io::FileDescriptor::write (jint b) { InterruptedIOException *iioe = new InterruptedIOException (JvNewStringLatin1 ("write interrupted")); iioe->bytesTransferred = bytesWritten; - throw iioe; + throw iioe; } if (bytesWritten != 1) - throw new IOException (JvNewStringLatin1 (winerr ())); + _Jv_ThrowIOException (); } else - throw new IOException (JvNewStringLatin1 (winerr ())); + _Jv_ThrowIOException (); // FIXME: loop until bytesWritten == 1 } @@ -175,11 +174,11 @@ java::io::FileDescriptor::write(jbyteArray b, jint offset, jint len) { InterruptedIOException *iioe = new InterruptedIOException (JvNewStringLatin1 ("write interrupted")); iioe->bytesTransferred = bytesWritten; - throw iioe; + throw iioe; } } else - throw new IOException (JvNewStringLatin1 (winerr ())); + _Jv_ThrowIOException (); // FIXME: loop until bytesWritten == len } @@ -189,7 +188,7 @@ java::io::FileDescriptor::close (void) HANDLE save = (HANDLE)fd; fd = (jint)INVALID_HANDLE_VALUE; if (! CloseHandle (save)) - throw new IOException (JvNewStringLatin1 (winerr ())); + _Jv_ThrowIOException (); } void @@ -201,46 +200,46 @@ java::io::FileDescriptor::setLength(jlong pos) // Get the original file pointer. if (SetFilePointer((HANDLE) fd, (LONG) 0, &liOrigFilePointer, - FILE_CURRENT) != (BOOL) 0 + FILE_CURRENT) != (BOOL) 0 && (GetLastError() != NO_ERROR)) - throw new IOException (JvNewStringLatin1 (winerr ())); + _Jv_ThrowIOException (); // Get the length of the file. if (SetFilePointer((HANDLE) fd, (LONG) 0, &liEndFilePointer, - FILE_END) != (BOOL) 0 + FILE_END) != (BOOL) 0 && (GetLastError() != NO_ERROR)) - throw new IOException (JvNewStringLatin1 (winerr ())); + _Jv_ThrowIOException (); if ((jlong)liEndFilePointer == pos) { // Restore the file pointer. if (liOrigFilePointer != liEndFilePointer) - { - if (SetFilePointer((HANDLE) fd, liOrigFilePointer, &liNewFilePointer, - FILE_BEGIN) != (BOOL) 0 - && (GetLastError() != NO_ERROR)) - throw new IOException (JvNewStringLatin1 (winerr ())); - } + { + if (SetFilePointer((HANDLE) fd, liOrigFilePointer, &liNewFilePointer, + FILE_BEGIN) != (BOOL) 0 + && (GetLastError() != NO_ERROR)) + _Jv_ThrowIOException (); + } return; } // Seek to the new end of file. if (SetFilePointer((HANDLE) fd, (LONG) pos, &liNewFilePointer, - FILE_BEGIN) != (BOOL) 0 + FILE_BEGIN) != (BOOL) 0 && (GetLastError() != NO_ERROR)) - throw new IOException (JvNewStringLatin1 (winerr ())); + _Jv_ThrowIOException (); // Truncate the file at this point. if (SetEndOfFile((HANDLE) fd) != (BOOL) 0 && (GetLastError() != NO_ERROR)) - throw new IOException (JvNewStringLatin1 (winerr ())); + _Jv_ThrowIOException (); if (liOrigFilePointer < liNewFilePointer) { // Restore the file pointer. if (SetFilePointer((HANDLE) fd, liOrigFilePointer, &liNewFilePointer, - FILE_BEGIN) != (BOOL) 0 - && (GetLastError() != NO_ERROR)) - throw new IOException (JvNewStringLatin1 (winerr ())); + FILE_BEGIN) != (BOOL) 0 + && (GetLastError() != NO_ERROR)) + _Jv_ThrowIOException (); } } @@ -262,7 +261,7 @@ java::io::FileDescriptor::seek (jlong pos, jint whence, jboolean eof_trunc) LONG high = pos >> 32; DWORD low = SetFilePointer ((HANDLE)fd, (DWORD)(0xffffffff & pos), &high, whence == SET ? FILE_BEGIN : FILE_CURRENT); if ((low == 0xffffffff) && (GetLastError () != NO_ERROR)) - throw new IOException (JvNewStringLatin1 (winerr ())); + _Jv_ThrowIOException (); return low; } @@ -272,7 +271,7 @@ java::io::FileDescriptor::getFilePointer(void) LONG high = 0; DWORD low = SetFilePointer ((HANDLE)fd, 0, &high, FILE_CURRENT); if ((low == 0xffffffff) && (GetLastError() != NO_ERROR)) - throw new IOException (JvNewStringLatin1 (winerr ())); + _Jv_ThrowIOException (); return (((jlong)high) << 32L) | (jlong)low; } @@ -298,7 +297,7 @@ java::io::FileDescriptor::read(void) if (GetLastError () == ERROR_BROKEN_PIPE) return -1; else - throw new IOException (JvNewStringLatin1 (winerr ())); + _Jv_ThrowIOException (); } if (! read) @@ -329,7 +328,7 @@ java::io::FileDescriptor::read(jbyteArray buffer, jint offset, jint count) if (GetLastError () == ERROR_BROKEN_PIPE) return -1; else - throw new IOException (JvNewStringLatin1 (winerr ())); + _Jv_ThrowIOException (); } if (read == 0) return -1; diff --git a/libjava/java/io/natFileWin32.cc b/libjava/java/io/natFileWin32.cc index 1e06832..cee6b00 100644 --- a/libjava/java/io/natFileWin32.cc +++ b/libjava/java/io/natFileWin32.cc @@ -9,15 +9,13 @@ Libgcj License. Please consult the file "LIBGCJ_LICENSE" for details. */ #include <config.h> +#include <platform.h> #include <stdio.h> #include <string.h> -#include <windows.h> #undef STRICT -#include <gcj/cni.h> -#include <jvm.h> #include <java/io/File.h> #include <java/io/IOException.h> #include <java/util/Vector.h> @@ -42,12 +40,9 @@ details. */ jboolean java::io::File::_access (jint query) { - jstring canon = getCanonicalPath(); - if (! canon) + JV_TEMP_UTF_STRING (canon, getCanonicalPath()); + if (!canon) return false; - char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (canon) + 1); - jsize total = JvGetStringUTFRegion (canon, 0, canon->length(), buf); - buf[total] = '\0'; JvAssert (query == READ || query == WRITE || query == EXISTS); @@ -55,7 +50,7 @@ java::io::File::_access (jint query) // If the file exists but cannot be read because of the secuirty attributes // on an NTFS disk this wont work (it reports it can be read but cant) // Could we use something from the security API? - DWORD attributes = GetFileAttributes (buf); + DWORD attributes = GetFileAttributes (canon); if ((query == EXISTS) || (query == READ)) return (attributes == 0xffffffff) ? false : true; else @@ -65,16 +60,13 @@ java::io::File::_access (jint query) jboolean java::io::File::_stat (jint query) { - jstring canon = getCanonicalPath(); - if (! canon) + JV_TEMP_UTF_STRING (canon, getCanonicalPath()); + if (!canon) return false; - char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (canon) + 1); - jsize total = JvGetStringUTFRegion (canon, 0, canon->length(), buf); - buf[total] = '\0'; JvAssert (query == DIRECTORY || query == ISFILE); - DWORD attributes = GetFileAttributes (buf); + DWORD attributes = GetFileAttributes (canon); if (attributes == 0xffffffff) return false; @@ -87,18 +79,15 @@ java::io::File::_stat (jint query) jlong java::io::File::attr (jint query) { - jstring canon = getCanonicalPath(); - if (! canon) + JV_TEMP_UTF_STRING (canon, getCanonicalPath()); + if (!canon) return false; - char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (canon) + 1); - jsize total = JvGetStringUTFRegion (canon, 0, canon->length(), buf); - buf[total] = '\0'; JvAssert (query == MODIFIED || query == LENGTH); WIN32_FIND_DATA info; HANDLE sHandle; - if ( ( sHandle = FindFirstFile( buf, &info)) == INVALID_HANDLE_VALUE) + if ( ( sHandle = FindFirstFile( canon, &info)) == INVALID_HANDLE_VALUE) return 0; FindClose( sHandle); @@ -119,13 +108,11 @@ java::io::File::attr (jint query) jstring java::io::File::getCanonicalPath (void) { - char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (path) + 1); - jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf); - buf[total] = '\0'; + JV_TEMP_UTF_STRING (cpath, path); LPTSTR unused; char buf2[MAX_PATH]; - if(!GetFullPathName(buf, MAX_PATH, buf2, &unused)) + if(!GetFullPathName(cpath, MAX_PATH, buf2, &unused)) throw new IOException (JvNewStringLatin1 ("GetFullPathName failed")); // FIXME: what encoding to assume for file names? This affects many @@ -152,7 +139,7 @@ java::io::File::isAbsolute (void) && (path->charAt(0) < 'A' || path->charAt(0) > 'Z')) return false; return (path->charAt(1) == ':' - && (path->charAt(2) == '/' || path->charAt(2) == '\\')); + && (path->charAt(2) == '/' || path->charAt(2) == '\\')); } void java::io::File::init_native () @@ -163,8 +150,8 @@ void java::io::File::init_native () jobjectArray java::io::File::performList (java::io::FilenameFilter *filter, - java::io::FileFilter *fileFilter, - java::lang::Class *clazz) + java::io::FileFilter *fileFilter, + java::lang::Class *clazz) { jstring canon = getCanonicalPath(); if (! canon) @@ -190,16 +177,16 @@ java::io::File::performList (java::io::FilenameFilter *filter, jstring name = JvNewStringUTF (data.cFileName); if (filter && !filter->accept(this, name)) - continue; + continue; if (clazz == &java::io::File::class$) - { + { java::io::File *file = new java::io::File (this, name); if (fileFilter && !fileFilter->accept(file)) - continue; - vec->addElement (file); - } - else - vec->addElement (name); + continue; + vec->addElement (file); + } + else + vec->addElement (name); } } while (FindNextFile (handle, &data)); @@ -217,53 +204,42 @@ java::io::File::performList (java::io::FilenameFilter *filter, jboolean java::io::File::performMkdir (void) { - char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (path) + 1); - jsize total = JvGetStringUTFRegion(path, 0, path->length(), buf); - buf[total] = '\0'; - - return (CreateDirectory(buf, NULL)) ? true : false; + JV_TEMP_UTF_STRING (cpath, path); + return (CreateDirectory(cpath, NULL)) ? true : false; } jboolean java::io::File::performRenameTo (File *dest) { - char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (path) + 1); - jsize total = JvGetStringUTFRegion(path, 0, path->length(), buf); - buf[total] = '\0'; - char *buf2 = (char *) __builtin_alloca (JvGetStringUTFLength (dest->path) - + 1); - total = JvGetStringUTFRegion(dest->path, 0, dest->path->length(), buf2); - buf2[total] = '\0'; - - return (MoveFile(buf, buf2)) ? true : false; + JV_TEMP_UTF_STRING (pathFrom, path); + JV_TEMP_UTF_STRING (pathTo, dest->path); + return (MoveFile(pathFrom, pathTo)) ? true : false; } jboolean java::io::File::performDelete () { - jstring canon = getCanonicalPath(); - char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (canon) + 1); - jsize total = JvGetStringUTFRegion(canon, 0, canon->length(), buf); - buf[total] = '\0'; + JV_TEMP_UTF_STRING (canon, getCanonicalPath()); + if (!canon) + return false; - DWORD attributes = GetFileAttributes (buf); + DWORD attributes = GetFileAttributes (canon); if (attributes == 0xffffffff) return false; if (attributes & FILE_ATTRIBUTE_DIRECTORY) - return (RemoveDirectory (buf)) ? true : false; + return (RemoveDirectory (canon)) ? true : false; else - return (DeleteFile (buf)) ? true : false; + return (DeleteFile (canon)) ? true : false; } jboolean java::io::File::performCreate (void) { - jstring canon = getCanonicalPath (); - char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (canon) + 1); - jsize total = JvGetStringUTFRegion (canon, 0, canon->length (), buf); - buf[total] = '\0'; + JV_TEMP_UTF_STRING (canon, getCanonicalPath()); + if (!canon) + return false; - HANDLE h = CreateFile (buf, 0, 0, NULL, CREATE_NEW, + HANDLE h = CreateFile (canon, 0, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); if (h != INVALID_HANDLE_VALUE) { @@ -281,15 +257,14 @@ jboolean java::io::File::performCreate (void) jboolean java::io::File::performSetReadOnly () { - jstring canon = getCanonicalPath (); - char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (canon) + 1); - jsize total = JvGetStringUTFRegion (canon, 0, canon->length (), buf); - buf[total] = '\0'; + JV_TEMP_UTF_STRING (canon, getCanonicalPath()); + if (!canon) + return false; - DWORD attrs = GetFileAttributes (buf); + DWORD attrs = GetFileAttributes (canon); if (attrs != INVALID_FILE_ATTRIBUTES) { - if (SetFileAttributes (buf, attrs | FILE_ATTRIBUTE_READONLY) != 0) + if (SetFileAttributes (canon, attrs | FILE_ATTRIBUTE_READONLY) != 0) return true; else return false; @@ -300,10 +275,9 @@ jboolean java::io::File::performSetReadOnly () jboolean java::io::File::performSetLastModified (jlong time) { - jstring canon = getCanonicalPath (); - char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (canon) + 1); - jsize total = JvGetStringUTFRegion (canon, 0, canon->length (), buf); - buf[total] = '\0'; + JV_TEMP_UTF_STRING (canon, getCanonicalPath()); + if (!canon) + return false; FILETIME modTime; long long mTime100ns = ((long long) time /* Ha! */ @@ -313,7 +287,7 @@ jboolean java::io::File::performSetLastModified (jlong time) modTime.dwHighDateTime = (DWORD) (mTime100ns >> 32); jboolean retVal = false; - HANDLE h = CreateFile (buf, FILE_WRITE_ATTRIBUTES, + HANDLE h = CreateFile (canon, FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); |