From: <pj...@us...> - 2008-07-17 03:21:37
|
Revision: 4961 http://jython.svn.sourceforge.net/jython/?rev=4961&view=rev Author: pjenvey Date: 2008-07-17 03:21:35 +0000 (Thu, 17 Jul 2008) Log Message: ----------- fix the symlink related tests by adding readlink, using _posix.lstat and utilizing _posix symlink stuff in posixpath. also utilize real stat results in posixpath, and re-enable ismount in ntpath since we can support it in posixpath Modified Paths: -------------- branches/asm/Lib/ntpath.py branches/asm/Lib/os.py branches/asm/Lib/posixpath.py Modified: branches/asm/Lib/ntpath.py =================================================================== --- branches/asm/Lib/ntpath.py 2008-07-17 01:43:59 UTC (rev 4960) +++ branches/asm/Lib/ntpath.py 2008-07-17 03:21:35 UTC (rev 4961) @@ -13,7 +13,7 @@ __all__ = ["normcase","isabs","join","splitdrive","split","splitext", "basename","dirname","commonprefix","getsize","getmtime", "getatime","getctime", "islink","exists","lexists","isdir","isfile", - "walk","expanduser","expandvars","normpath","abspath", + "ismount","walk","expanduser","expandvars","normpath","abspath", "splitunc","curdir","pardir","sep","pathsep","defpath","altsep", "extsep","devnull","realpath","supports_unicode_filenames"] @@ -287,21 +287,18 @@ return stat.S_ISREG(st.st_mode) -if os.name != 'java': - # Is a path a mount point? Either a root (with or without drive letter) - # or an UNC path with at most a / or \ after the mount point. +# Is a path a mount point? Either a root (with or without drive letter) +# or an UNC path with at most a / or \ after the mount point. - def ismount(path): - """Test whether a path is a mount point (defined as root of drive)""" - unc, rest = splitunc(path) - if unc: - return rest in ("", "/", "\\") - p = splitdrive(path)[1] - return len(p) == 1 and p[0] in '/\\' +def ismount(path): + """Test whether a path is a mount point (defined as root of drive)""" + unc, rest = splitunc(path) + if unc: + return rest in ("", "/", "\\") + p = splitdrive(path)[1] + return len(p) == 1 and p[0] in '/\\' - __all__.append("ismount") - # Directory tree walk. # For each directory under top (including top itself, but excluding # '.' and '..'), func(arg, dirname, filenames) is called, where Modified: branches/asm/Lib/os.py =================================================================== --- branches/asm/Lib/os.py 2008-07-17 01:43:59 UTC (rev 4960) +++ branches/asm/Lib/os.py 2008-07-17 03:21:35 UTC (rev 4961) @@ -283,7 +283,6 @@ just the rightmost) will be created if it does not exist. The optional parameter is currently ignored. """ - sys_path = sys.getPath(path) if File(sys_path).mkdirs(): return @@ -451,6 +450,16 @@ Like stat(path), but do not follow symbolic links. """ + abs_path = sys.getPath(path) + try: + s = _posix.lstat(abs_path) + return stat_result((s.mode(), s.ino(), s.dev(), s.nlink(), + s.uid(), s.gid(), s.st_size(), + s.atime(), s.mtime(), s.ctime())) + except NotImplementedError: + pass + except: + raise f = File(sys.getPath(path)) abs_parent = f.getAbsoluteFile().getParentFile() if not abs_parent: @@ -636,8 +645,16 @@ Create a symbolic link pointing to src named dst. """ - return _posix.symlink(src, dst) + _posix.symlink(src, sys.getPath(dst)) + def readlink(path): + """readlink(path) -> path + + Return a string representing the path to which the symbolic link + points. + """ + return _posix.readlink(sys.getPath(path)) + # Provide lazy popen*, and system objects # Do these lazily, as most jython programs don't need them, # and they are very expensive to initialize Modified: branches/asm/Lib/posixpath.py =================================================================== --- branches/asm/Lib/posixpath.py 2008-07-17 01:43:59 UTC (rev 4960) +++ branches/asm/Lib/posixpath.py 2008-07-17 03:21:35 UTC (rev 4961) @@ -33,6 +33,9 @@ altsep = None devnull = '/dev/null' +# XXX: There should be a global way of disabling native JNA posix +native_posix = True + # Normalize the case of a pathname. Trivial in Posix, string.lower on Mac. # On MS-DOS this may also turn slashes into backslashes; however, other # normalizations (such as optimizing '../' away) are not allowed @@ -215,7 +218,7 @@ # Are two filenames really pointing to the same file? -if os.name == 'java': +if not native_posix: def samefile(f1, f2): """Test whether two pathnames reference the same actual file""" canon1 = java.io.File(_ensure_str(f1)).getCanonicalPath() @@ -241,6 +244,7 @@ return samestat(s1, s2) +if native_posix: # Are two stat buffers (obtained from stat, fstat or lstat) # describing the same file? @@ -438,7 +442,7 @@ return abspath(filename) -if os.name == 'java': +if not native_posix: def _resolve_link(path): """Internal helper function. Takes a path and follows symlinks until we either arrive at something that isn't a symlink, or This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |