Back to index

enigmail  1.4.3
Classes | Functions | Variables
unit-JarMaker Namespace Reference

Classes

class  FILETIME
class  BY_HANDLE_FILE_INFORMATION
class  _TreeDiff
class  TestJarMaker

Functions

def symlinks_supported
def _getfileinfo
def is_symlink_to

Variables

 DWORD = ctypes.c_ulong
tuple LPDWORD = POINTER(DWORD)
 HANDLE = ctypes.c_void_p
int GENERIC_READ = 0x80000000
int FILE_SHARE_READ = 0x00000001
int OPEN_EXISTING = 3
int MAX_PATH = 260
 CreateFile = ctypes.windll.kernel32.CreateFileA
 GetFileInformationByHandle = ctypes.windll.kernel32.GetFileInformationByHandle
 GetVolumePathName = ctypes.windll.kernel32.GetVolumePathNameA
 GetVolumeInformation = ctypes.windll.kernel32.GetVolumeInformationA

Function Documentation

def unit-JarMaker._getfileinfo (   path) [private]
Return information for the given file. This only works on Windows.

Definition at line 83 of file unit-JarMaker.py.

00083 
00084 def _getfileinfo(path):
00085     """Return information for the given file. This only works on Windows."""
00086     fh = CreateFile(path, GENERIC_READ, FILE_SHARE_READ, None, OPEN_EXISTING, 0, None)
00087     if fh is None:
00088         raise WinError()
00089     info = BY_HANDLE_FILE_INFORMATION()
00090     rv = GetFileInformationByHandle(fh, info)
00091     if rv == 0:
00092         raise WinError()
00093     return info

Here is the caller graph for this function:

def unit-JarMaker.is_symlink_to (   dest,
  src 
)

Definition at line 94 of file unit-JarMaker.py.

00094 
00095 def is_symlink_to(dest, src):
00096     if sys.platform == "win32":
00097         # Check if both are on the same volume and have the same file ID
00098         destinfo = _getfileinfo(dest)
00099         srcinfo = _getfileinfo(src)
00100         return (destinfo.dwVolumeSerialNumber == srcinfo.dwVolumeSerialNumber and
00101                 destinfo.nFileIndexHigh == srcinfo.nFileIndexHigh and
00102                 destinfo.nFileIndexLow == srcinfo.nFileIndexLow)
00103     else:
00104         # Read the link and check if it is correct
00105         if not os.path.islink(dest):
00106             return False
00107         target = os.path.abspath(os.readlink(dest))
00108         abssrc = os.path.abspath(src)
00109         return target == abssrc

Here is the call graph for this function:

Here is the caller graph for this function:

def unit-JarMaker.symlinks_supported (   path)

Definition at line 63 of file unit-JarMaker.py.

00063 
00064 def symlinks_supported(path):
00065     if sys.platform == "win32":
00066         # Add 1 for a trailing backslash if necessary, and 1 for the terminating
00067         # null character.
00068         volpath = ctypes.create_string_buffer(len(path) + 2)
00069         rv = GetVolumePathName(path, volpath, len(volpath))
00070         if rv == 0:
00071             raise WinError()
00072 
00073         fsname = ctypes.create_string_buffer(MAX_PATH + 1)
00074         rv = GetVolumeInformation(volpath, None, 0, None, None, None, fsname,
00075                                   len(fsname))
00076         if rv == 0:
00077             raise WinError()
00078 
00079         # Return true only if the fsname is NTFS
00080         return fsname.value == "NTFS"
00081     else:
00082         return True

Here is the caller graph for this function:


Variable Documentation

unit-JarMaker.CreateFile = ctypes.windll.kernel32.CreateFileA

Definition at line 41 of file unit-JarMaker.py.

unit-JarMaker.DWORD = ctypes.c_ulong

Definition at line 16 of file unit-JarMaker.py.

int unit-JarMaker.FILE_SHARE_READ = 0x00000001

Definition at line 20 of file unit-JarMaker.py.

int unit-JarMaker.GENERIC_READ = 0x80000000

Definition at line 19 of file unit-JarMaker.py.

unit-JarMaker.GetFileInformationByHandle = ctypes.windll.kernel32.GetFileInformationByHandle

Definition at line 47 of file unit-JarMaker.py.

unit-JarMaker.GetVolumeInformation = ctypes.windll.kernel32.GetVolumeInformationA

Definition at line 57 of file unit-JarMaker.py.

unit-JarMaker.GetVolumePathName = ctypes.windll.kernel32.GetVolumePathNameA

Definition at line 52 of file unit-JarMaker.py.

unit-JarMaker.HANDLE = ctypes.c_void_p

Definition at line 18 of file unit-JarMaker.py.

tuple unit-JarMaker.LPDWORD = POINTER(DWORD)

Definition at line 17 of file unit-JarMaker.py.

int unit-JarMaker.MAX_PATH = 260

Definition at line 22 of file unit-JarMaker.py.

int unit-JarMaker.OPEN_EXISTING = 3

Definition at line 21 of file unit-JarMaker.py.