예제 #1
0
def compress(file_path):
    print("Compress", file_path)
    dcx = Dcx()
    load_success = dcx.load_decompressed(file_path)
    if not load_success:
        return
    dcx_path = file_path + ".dcx"
    dcx.save(dcx_path)
예제 #2
0
def decompress(dcx_path):
    print("Decompress", dcx_path)
    dcx = Dcx()
    load_success = dcx.load(dcx_path)
    if not load_success:
        return
    basefile_path = os.path.splitext(dcx_path)[0]
    dcx.save_decompressed(basefile_path)
예제 #3
0
    def _compress(file_path, remove_original = True):
        """ Compress the file in a DCX file and can remove the original. """
        dcx = Dcx()
        import_success = dcx.load_decompressed(file_path)
        if not import_success:
            return False

        dcx_path = file_path + ".dcx"
        export_success = dcx.save(dcx_path)

        if remove_original:
            os.remove(file_path)
        return export_success
예제 #4
0
    def _decompress(file_path, remove_dcx = True):
        """ Decompress that file and remove the compressed original (DCX) if
        remove_dcx is True. Return True on success. """
        dcx = Dcx()
        import_success = dcx.load(file_path)
        if not import_success:
            return False

        decompressed_path = os.path.splitext(file_path)[0]  # remove the .dcx
        export_success = dcx.save_decompressed(decompressed_path)
        if not export_success:
            return False

        if remove_dcx:
            os.remove(file_path)
        return True