src/solaris/native/java/io/UnixFileSystem_md.c

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -75,11 +75,11 @@
 {
     jstring rv = NULL;
 
     WITH_PLATFORM_STRING(env, pathname, path) {
         char canonicalPath[JVM_MAXPATHLEN];
-        if (canonicalize(JVM_NativePath((char *)path),
+        if (canonicalize((char *)path,
                          canonicalPath, JVM_MAXPATHLEN) < 0) {
             JNU_ThrowIOExceptionWithLastError(env, "Bad pathname");
         } else {
 #ifdef MACOSX
             rv = newStringPlatform(env, canonicalPath);

@@ -239,24 +239,23 @@
                                                   jstring pathname)
 {
     jboolean rv = JNI_FALSE;
 
     WITH_PLATFORM_STRING(env, pathname, path) {
-        int fd;
-        if (!strcmp (path, "/")) {
-            fd = JVM_EEXIST;    /* The root directory always exists */
-        } else {
-            fd = JVM_Open(path, JVM_O_RDWR | JVM_O_CREAT | JVM_O_EXCL, 0666);
-        }
+        FD fd;
+        /* The root directory always exists */
+        if (strcmp (path, "/")) {
+            fd = handleOpen(path, O_RDWR | O_CREAT | O_EXCL, 0666);
         if (fd < 0) {
-            if (fd != JVM_EEXIST) {
+                if (errno != EEXIST)
                 JNU_ThrowIOExceptionWithLastError(env, path);
-            }
         } else {
-            JVM_Close(fd);
+                if (close(fd) == -1)
+                    JNU_ThrowIOExceptionWithLastError(env, path);
             rv = JNI_TRUE;
         }
+        }
     } END_PLATFORM_STRING(env, path);
     return rv;
 }