def main(random_file_num): print('WARNING: This will wipe out your partition.') os.system('rmdir /S /Q \"%s\"' % ROOT) for root, dirs, files in os.walk(ROOT): for f in files: fp = os.path.join(root, f) os.chmod(fp, stat.S_IWUSR) os.remove(fp) for d in dirs: os.rmdir(os.path.join(root, d)) for i in range(random_file_num): write_random_file(usable_random_fp(root=ROOT)) with WindowsPhysicalDriveStream(2) as stream: t1 = time.time() partition = next(get_drive_obj(stream)) entries = partition.get_entries() t2 = time.time() print('Partition type is %s. ' 'Read %s entries, ' 'which took %s' % (partition.type, entries.shape[0], t2 - t1)) return t2 - t1, entries.shape[0]
# encoding: utf-8 from drive.disk import get_drive_obj from drive.fs.fat32 import FAT32 from stream import ImageStream, WindowsPhysicalDriveStream stream = ImageStream('d:/edt.raw') address, port = '127.0.0.1', 8000 partitions = [] for partition in get_drive_obj(stream): if partition: if partition.type == FAT32.type: partitions.append(partition)