Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 47 additions & 5 deletions tools/splitFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,18 @@
splitSize = 0xFFFF0000 # 4,294,901,760 bytes
chunkSize = 0x8000 # 32,768 bytes

FNULL = open(os.devnull, 'w')

def checkCommand(name):
from shutil import which
return which(name) is not None

from os.path import splitext
def splitext_(path):
if len(path.split('.')) > 2:
return path.split('.')[0],'.'.join(path.split('.')[-2:])
return splitext(path)
def splitQuick(filepath):
fileSize = os.path.getsize(filepath)
info = shutil.disk_usage(os.path.dirname(os.path.abspath(filepath)))
Expand All @@ -42,8 +48,26 @@ def splitQuick(filepath):
shutil.rmtree(dir)
os.makedirs(dir)

if os.path.exists(dir):
subprocess.call(['attrib', '+a', dir])
if (os.name == "nt"):
if os.path.exists(dir):
subprocess.call(['attrib', '+a', dir])
elif (os.name == "posix"):
if checkCommand("mattrib"):
if os.path.exists(dir):
try:
subprocess.check_call(['mattrib', '+a', dir], stdin=FNULL, stdout=FNULL, stderr=FNULL)
except subprocess.CalledProcessError:
print('Could not set archivbit! Probably not a Windows Filesystem!')
except OSError:
pass # executable not found
else:
print('Could not set archivbit!')
print('mtools are not installed.')
print('You need to set it manually for the folder! Or install mtools and restart the job.')
else:
print('Could not set archivbit! Environment unknown!')
print('You need to set it manually for the folder!')


# Move input file to directory and rename it to first part
filename = os.path.basename(filepath)
Expand Down Expand Up @@ -108,8 +132,26 @@ def splitCopy(filepath):
shutil.rmtree(dir)
os.makedirs(dir)

if os.path.exists(dir):
subprocess.call(['attrib', '+a', dir])
if (os.name == "nt"):
if os.path.exists(dir):
subprocess.check_call(['attrib', '+a', dir])
elif (os.name == "posix"):
if checkCommand("mattrib"):
if os.path.exists(dir):
try:
subprocess.check_call(['mattrib', '+a', dir], stdin=FNULL, stdout=FNULL, stderr=FNULL)
except subprocess.CalledProcessError:
print('Could not set archivbit! Probably not a Windows Filesystem!')
except OSError:
pass # executable not found
else:
print('Could not set archivbit!')
print('mtools are not installed.')
print('You need to set it manually for the folder! Or install mtools and restart the job.')
else:
print('Could not set archivbit! Environment unknown!')
print('You need to set it manually for the folder!')


remainingSize = fileSize

Expand Down