mirror of
https://github.com/RasppleII/a2server.git
synced 2025-04-10 13:36:59 +00:00
cppo: SHK has same process and output as HDV
resource forks are not displayed if not using -e or -ad
This commit is contained in:
parent
8327a5eb8d
commit
e0a78c5756
@ -60,6 +60,7 @@ g.activeFileName = None
|
||||
g.activeFileSize = None
|
||||
g.activeFileBytesCopied = 0
|
||||
g.resourceFork = 0
|
||||
g.shk_hasrf = ""
|
||||
g.shk_rfork = 0
|
||||
|
||||
g.PDOSPATH = []
|
||||
@ -410,12 +411,16 @@ def copyFile(arg1, arg2):
|
||||
g.activeFileBytesCopied = 0
|
||||
|
||||
if g.SHK:
|
||||
if g.EX or not g.shk_rfork:
|
||||
with open(os.path.join(arg1, arg2), 'rb') as infile:
|
||||
g.outFileData += infile.read()
|
||||
elif g.shk_rfork and g.AD:
|
||||
with open(os.path.join(arg1, arg2), 'rb') as infile:
|
||||
g.exFileData += infile.read()
|
||||
with open(os.path.join(arg1, arg2), 'rb') as infile:
|
||||
g.outFileData += infile.read()
|
||||
if g.shk_hasrf:
|
||||
print(" [data fork]")
|
||||
if (g.EX or g.AD):
|
||||
print(" [resource fork]")
|
||||
if (g.exFileData == None):
|
||||
g.exFileData = bytearray(b'')
|
||||
with open(os.path.join(arg1, (arg2 + "r")), 'rb') as infile:
|
||||
g.exFileData += infile.read()
|
||||
else: # ProDOS or DOS 3.3
|
||||
storageType = getStorageType(arg1, arg2)
|
||||
keyPointer = getKeyPointer(arg1, arg2)
|
||||
@ -520,14 +525,7 @@ def processEntry(arg1, arg2):
|
||||
eTargetName = None
|
||||
g.exFileData = None
|
||||
g.outFileData = bytearray(b'')
|
||||
g.shk_hasrf = ""
|
||||
g.shk_rfork = False
|
||||
if g.SHK: # ShrinkIt archive
|
||||
if (arg2[-1:] == "r" and os.path.isfile(os.path.join(arg1,arg2[:-1]))):
|
||||
g.shk_rfork = True
|
||||
elif (not g.EX and not g.AD and
|
||||
os.path.isfile(os.path.join(arg1, (arg2 + "r")))):
|
||||
g.shk_hasrf = "+"
|
||||
g.activeFileName = (arg2 if g.EX else arg2.split('#')[0])
|
||||
origFileName = g.activeFileName
|
||||
else: # ProDOS or DOS 3.3 image
|
||||
@ -561,18 +559,13 @@ def processEntry(arg1, arg2):
|
||||
if (not g.extractFile or
|
||||
(os.path.basename(g.extractFile) ==
|
||||
origFileName.split('#')[0])):
|
||||
if (not (g.DIR and (g.shk_rfork and not g.EX and not g.AD))):
|
||||
print(" " + g.activeFileName + g.shk_hasrf +
|
||||
((" [" + origFileName + "] ")
|
||||
if (g.PNAME and (origFileName != g.activeFileName))
|
||||
else "") +
|
||||
((" [resource fork]" +
|
||||
("" if (g.AD or g.EX)
|
||||
else " (ignoring, use -e or -ad to keep)"))
|
||||
if g.shk_rfork
|
||||
else ("+" if (not g.SHK and
|
||||
getStorageType(arg1, arg2) == 5)
|
||||
else "")))
|
||||
print(" " + g.activeFileName.split("#")[0] +
|
||||
("+" if (g.shk_hasrf or
|
||||
(not g.SHK and getStorageType(arg1, arg2) == 5))
|
||||
else "") +
|
||||
((" [" + origFileName + "] ")
|
||||
if (g.PNAME and (origFileName != g.activeFileName))
|
||||
else ""))
|
||||
if g.DIR:
|
||||
return
|
||||
if not g.targetName:
|
||||
@ -590,8 +583,7 @@ def processEntry(arg1, arg2):
|
||||
copyFile(arg1, arg2)
|
||||
saveName = (g.targetDir + "/" +
|
||||
(eTargetName if eTargetName else g.targetName))
|
||||
if not (g.shk_rfork and not g.EX):
|
||||
saveFile(saveName, g.outFileData)
|
||||
saveFile(saveName, g.outFileData)
|
||||
creationDate = getCreationDate(arg1, arg2)
|
||||
modifiedDate = getModifiedDate(arg1, arg2)
|
||||
if (creationDate is None and modifiedDate is not None):
|
||||
@ -620,7 +612,7 @@ def processEntry(arg1, arg2):
|
||||
writechars(g.exFileData, 657, b'pdos')
|
||||
saveFile(ADfilePath, g.exFileData)
|
||||
touch(saveName, modifiedDate)
|
||||
if g.EX and not g.shk_rfork: # extended name from ProDOS image
|
||||
if g.EX: # extended name from ProDOS image
|
||||
if (g.exFileData != None):
|
||||
saveFile((saveName + "r"), g.exFileData)
|
||||
touch((saveName + "r"), modifiedDate)
|
||||
@ -660,9 +652,8 @@ def processForkedFile(arg1):
|
||||
readcharHex(g.imageData, forkStart+f+6) +
|
||||
readcharHex(g.imageData, forkStart+f+5))
|
||||
# print(">>>" + rsrcForkLenHex)
|
||||
print(" [resource fork]" +
|
||||
("" if (g.AD or g.EX)
|
||||
else " (ignoring, use -e or -ad to keep)"))
|
||||
if (g.AD or g.EX):
|
||||
print(" [resource fork]")
|
||||
if g.AD:
|
||||
writecharsHex(g.exFileData, 35, rsrcForkLenHex)
|
||||
else:
|
||||
@ -1175,7 +1166,8 @@ if g.SHK:
|
||||
print(" and omit any leading slash or colon.")
|
||||
sys.exit(1)
|
||||
if g.extractFile:
|
||||
extractPath = (unshkdir + "/" + (args[2].replace(':', '/')))
|
||||
g.extractFile = g.extractFile.replace(':', '/')
|
||||
extractPath = (unshkdir + "/" + g.extractFile)
|
||||
extractPathDir = os.path.dirname(extractPath)
|
||||
# move the extracted file to the root
|
||||
newunshkdir = ("/tmp/cppo-" + str(uuid.uuid4()))
|
||||
@ -1217,7 +1209,15 @@ if g.SHK:
|
||||
if "/".join(dirName.split('/')[3:])
|
||||
else "(top level)")
|
||||
for fname in sorted(fileList):
|
||||
processEntry(dirName, fname)
|
||||
g.shk_hasrf = ""
|
||||
g.shk_rfork = False
|
||||
if (fname[-1:] == "r" and
|
||||
os.path.isfile(os.path.join(dirName, fname[:-1]))):
|
||||
g.shk_rfork = True
|
||||
elif (os.path.isfile(os.path.join(dirName, (fname + "r")))):
|
||||
g.shk_hasrf = "+"
|
||||
if not g.shk_rfork:
|
||||
processEntry(dirName, fname)
|
||||
shutil.rmtree(unshkdir, True)
|
||||
syncExit()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user