Beispiel #1
0
 def is_partition_supported(folder):
     if folder[-1] != os.path.sep:
         folder = folder + os.path.sep
     if win32file.GetDriveType(folder) != win32file.DRIVE_FIXED:
         return False
     volume = win32file.GetVolumePathName(folder)
     t = win32api.GetVolumeInformation(volume)
     return t[-1] == 'NTFS'
Beispiel #2
0
 def is_partition_supported(path: Path) -> bool:
     """
     Only NTFS is supported on Windows.
     FAT and FAT32 do not support extended attributes.
     """
     folder = str(path)
     if folder[-1] != os.path.sep:
         folder += os.path.sep
     if win32file.GetDriveType(folder) != win32file.DRIVE_FIXED:
         return False
     volume = win32file.GetVolumePathName(folder)
     return win32api.GetVolumeInformation(volume)[-1] == "NTFS"
Beispiel #3
0
def GetRawDevice(path):
    """Resolves the raw device that contains the path.

  Args:
    path: A path to examine.

  Returns:
    A pathspec to read the raw device as well as the modified path to read
    within the raw device. This is usually the path without the mount point.

  Raises:
    IOError: if the path does not exist or some unexpected behaviour occurs.
  """
    path = CanonicalPathToLocalPath(path)
    # Try to expand the shortened paths
    try:
        path = win32file.GetLongPathName(path)
    except pywintypes.error:
        pass

    try:
        mount_point = win32file.GetVolumePathName(path)
    except pywintypes.error as details:
        logging.info("path not found. %s", details)
        raise IOError("No mountpoint for path: %s", path)

    if not path.startswith(mount_point):
        stripped_mp = mount_point.rstrip("\\")
        if not path.startswith(stripped_mp):
            raise IOError("path %s is not mounted under %s" %
                          (path, mount_point))

    corrected_path = LocalPathToCanonicalPath(path[len(mount_point):])
    corrected_path = utils.NormalizePath(corrected_path)

    volume = win32file.GetVolumeNameForVolumeMountPoint(mount_point).rstrip(
        "\\")
    volume = LocalPathToCanonicalPath(volume)

    # The pathspec for the raw volume
    result = rdf_paths.PathSpec(path=volume,
                                pathtype=rdf_paths.PathSpec.PathType.OS,
                                mount_point=mount_point.rstrip("\\"))

    return result, corrected_path
Beispiel #4
0
 def is_same_partition(self, folder1, folder2):
     import win32file
     volume = win32file.GetVolumePathName(folder1)
     return volume == win32file.GetVolumePathName(folder2)
Beispiel #5
0
 def is_same_partition(folder1, folder2):
     volume = win32file.GetVolumePathName(folder1)
     return volume == win32file.GetVolumePathName(folder2)