mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	- Move functions common to all path modules into genericpath.py and have the
OS speicifc path modules import them. - Have os2emxpath import common functions fron ntpath instead of using copies
This commit is contained in:
		
							parent
							
								
									4582d7d905
								
							
						
					
					
						commit
						7b60464ceb
					
				
					 6 changed files with 273 additions and 476 deletions
				
			
		|  | @ -2,6 +2,7 @@ | |||
| 
 | ||||
| import os | ||||
| from stat import * | ||||
| from genericpath import * | ||||
| 
 | ||||
| __all__ = ["normcase","isabs","join","splitdrive","split","splitext", | ||||
|            "basename","dirname","commonprefix","getsize","getmtime", | ||||
|  | @ -101,31 +102,6 @@ def ismount(s): | |||
|     components = split(s) | ||||
|     return len(components) == 2 and components[1] == '' | ||||
| 
 | ||||
| def isdir(s): | ||||
|     """Return true if the pathname refers to an existing directory.""" | ||||
| 
 | ||||
|     try: | ||||
|         st = os.stat(s) | ||||
|     except os.error: | ||||
|         return 0 | ||||
|     return S_ISDIR(st.st_mode) | ||||
| 
 | ||||
| 
 | ||||
| # Get size, mtime, atime of files. | ||||
| 
 | ||||
| def getsize(filename): | ||||
|     """Return the size of a file, reported by os.stat().""" | ||||
|     return os.stat(filename).st_size | ||||
| 
 | ||||
| def getmtime(filename): | ||||
|     """Return the last modification time of a file, reported by os.stat().""" | ||||
|     return os.stat(filename).st_mtime | ||||
| 
 | ||||
| def getatime(filename): | ||||
|     """Return the last access time of a file, reported by os.stat().""" | ||||
|     return os.stat(filename).st_atime | ||||
| 
 | ||||
| 
 | ||||
| def islink(s): | ||||
|     """Return true if the pathname refers to a symbolic link.""" | ||||
| 
 | ||||
|  | @ -135,29 +111,6 @@ def islink(s): | |||
|     except: | ||||
|         return False | ||||
| 
 | ||||
| 
 | ||||
| def isfile(s): | ||||
|     """Return true if the pathname refers to an existing regular file.""" | ||||
| 
 | ||||
|     try: | ||||
|         st = os.stat(s) | ||||
|     except os.error: | ||||
|         return False | ||||
|     return S_ISREG(st.st_mode) | ||||
| 
 | ||||
| def getctime(filename): | ||||
|     """Return the creation time of a file, reported by os.stat().""" | ||||
|     return os.stat(filename).st_ctime | ||||
| 
 | ||||
| def exists(s): | ||||
|     """Test whether a path exists.  Returns False for broken symbolic links""" | ||||
| 
 | ||||
|     try: | ||||
|         st = os.stat(s) | ||||
|     except os.error: | ||||
|         return False | ||||
|     return True | ||||
| 
 | ||||
| # Is `stat`/`lstat` a meaningful difference on the Mac?  This is safe in any | ||||
| # case. | ||||
| 
 | ||||
|  | @ -170,20 +123,6 @@ def lexists(path): | |||
|         return False | ||||
|     return True | ||||
| 
 | ||||
| # Return the longest prefix of all list elements. | ||||
| 
 | ||||
| def commonprefix(m): | ||||
|     "Given a list of pathnames, returns the longest common leading component" | ||||
|     if not m: return '' | ||||
|     s1 = min(m) | ||||
|     s2 = max(m) | ||||
|     n = min(len(s1), len(s2)) | ||||
|     for i in xrange(n): | ||||
|         if s1[i] != s2[i]: | ||||
|             return s1[:i] | ||||
|     return s1[:n] | ||||
| 
 | ||||
| 
 | ||||
| def expandvars(path): | ||||
|     """Dummy to retain interface-compatibility with other operating systems.""" | ||||
|     return path | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Jack Diederich
						Jack Diederich