[pypy-svn] r67729 - pypy/trunk/pypy/translator/jvm/src/pypy

antocuni at codespeak.net antocuni at codespeak.net
Thu Sep 17 12:00:00 CEST 2009


Author: antocuni
Date: Thu Sep 17 12:00:00 2009
New Revision: 67729

Modified:
   pypy/trunk/pypy/translator/jvm/src/pypy/PyPy.java
   pypy/trunk/pypy/translator/jvm/src/pypy/ll_os.java
Log:
(yoli, antocuni) this has been waiting forever in my wc. Fix ll_os on windows for the jvm backend


Modified: pypy/trunk/pypy/translator/jvm/src/pypy/PyPy.java
==============================================================================
--- pypy/trunk/pypy/translator/jvm/src/pypy/PyPy.java	(original)
+++ pypy/trunk/pypy/translator/jvm/src/pypy/PyPy.java	Thu Sep 17 12:00:00 2009
@@ -924,7 +924,7 @@
     
     public String ll_join(String a, String b)
     {
-        return a + "/" + b; // XXX
+        return a + File.separator + b;
     }
 
     public String ll_strtod_formatd(String format, double d)

Modified: pypy/trunk/pypy/translator/jvm/src/pypy/ll_os.java
==============================================================================
--- pypy/trunk/pypy/translator/jvm/src/pypy/ll_os.java	(original)
+++ pypy/trunk/pypy/translator/jvm/src/pypy/ll_os.java	Thu Sep 17 12:00:00 2009
@@ -10,6 +10,7 @@
 
 import com.sun.jna.Library;
 import com.sun.jna.Native;
+import com.sun.jna.Platform;
 
 abstract class FileWrapper
 {
@@ -172,15 +173,29 @@
         public int symlink(String path1, String path2);
         public int access(String path, int mode);
     }
+
+    static public interface Msvcrt extends Library {
+         public int _access(String path, int mode);
+    }
+
     static final Libc libc;
+    static final Msvcrt msvcrt;
     static {
-        Libc res;
+        Libc res = null;
+        Msvcrt vcrt = null;
         try {
-            res = (Libc) Native.loadLibrary("c", Libc.class);
+            if ((Platform.isWindows())) {
+                vcrt = (Msvcrt) Native.loadLibrary("msvcrt", Msvcrt.class);
+            }
+            else {
+                res = (Libc) Native.loadLibrary("c", Libc.class);
+            }
         } catch (Throwable t) {
             res = null;
+            vcrt = null;
         }
         libc = res;
+        msvcrt = vcrt;
     }
 
     // NB: these values are those used by Windows and they differs
@@ -298,6 +313,10 @@
         //if ((mode & X_OK) != 0 && !file.canExecute())
         //    return false;
         
+        if (msvcrt != null) {
+            return msvcrt._access(path, mode) == 0;
+        }
+        
         return libc.access(path, mode) == 0; // note that 0==success
     }
 
@@ -532,7 +551,7 @@
 
     public void checkLibc() {
         if (libc == null)
-            throwOSError(EPERM, "jna.jar required");
+            throwOSError(EPERM, "jna.jar and an Unix are required");
     }
 
     public int ll_os_getpid() 
@@ -548,4 +567,9 @@
         if (res != 0)
             throwOSError(res, "");
     }
+
+    public String posix__getfullpathname(String name)
+    {
+        return new File(name).getAbsolutePath();
+    }
 }



More information about the Pypy-commit mailing list