Index: Lib/javaos.py =================================================================== --- Lib/javaos.py (revision 4218) +++ Lib/javaos.py (working copy) @@ -100,6 +100,35 @@ from os.path import curdir, pardir, sep, pathsep, defpath, extsep, altsep linesep = java.lang.System.getProperty('line.separator') +from org.jruby.ext.posix import POSIXHandler, POSIXFactory +from java.lang import System + +class PythonPOSIXHandler(POSIXHandler): + def error(self, errors, msg): + pass # implement + def unimplementedError(self, msg): + pass # implement + def warn(self, id, msg, rest): + pass # implement + def isVerbose(self): + return False + def getCurrentWorkingDirectory(self): + import os + return os.getcwd() + def getEnv(self): + import os + return os.environ + def getInputStream(self): + return System.in # handle resetting + def getOutputStream(self): + return System.out # handle resetting + def getPID(self): + return 0 # ??? + def getErrorStream(self): + return System.err # handle resetting + +_posix = POSIXFactory.getPOSIX(PythonPosixHandler(), True) + # open for reading only O_RDONLY = 0x0 # open for writing only @@ -221,6 +250,13 @@ raise OSError(0, 'No such directory', path) return list(l) +def chmod(path, mode): + """chmod(path, mode) + + Change the access permissions of a file. + """ + _posix.chmod(path, mode) + def mkdir(path, mode='ignored'): """mkdir(path [, mode=0777])