Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import win32file
- import winioctlcon
- import win32con
- import struct
- def set_file_compression(filename, state):
- handle = win32file.CreateFile(filename
- , win32file.GENERIC_READ | win32file.GENERIC_WRITE
- , 0, None
- , win32file.OPEN_EXISTING
- , 0, None)
- if state:
- buffer = struct.pack('H', win32con.COMPRESSION_FORMAT_DEFAULT)
- else:
- buffer = struct.pack('H', win32con.COMPRESSION_FORMAT_NONE)
- win32file.DeviceIoControl(Device = handle
- , IoControlCode = winioctlcon.FSCTL_SET_COMPRESSION
- , InBuffer = buffer
- , OutBuffer = None)
- win32file.CloseHandle(handle)
- set_file_compression('test.dat', False)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement