2017-06-20 19:48:22 -07:00
|
|
|
#!/usr/bin/env python3
|
2017-06-20 19:27:38 -07:00
|
|
|
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=python:
|
|
|
|
|
|
|
|
"""cppo: Copy/catalog files from a ProDOS/DOS 3.3/ShrinkIt image/archive.
|
|
|
|
|
|
|
|
copy all files: cppo [options] imagefile target_directory
|
|
|
|
copy one file : cppo [options] imagefile /extract/path target_path
|
|
|
|
catalog image : cppo -cat [options] imagefile
|
|
|
|
|
|
|
|
options:
|
|
|
|
-shk: ShrinkIt archive as source (also auto-enabled by filename).
|
|
|
|
-ad : Netatalk-compatible AppleDouble metadata files and resource forks.
|
|
|
|
-e : Nulib2-compatible filenames with type/auxtype and resource forks.
|
|
|
|
-uc : Copy GS/OS mixed case filenames as uppercase.
|
|
|
|
-pro: Adapt DOS 3.3 names to ProDOS and remove addr/len from file data.
|
|
|
|
|
|
|
|
/extract/path examples:
|
|
|
|
/FULL/PRODOS/PATH (ProDOS image source)
|
|
|
|
"MY FILENAME" (DOS 3.3 image source)
|
|
|
|
Dir:SubDir:FileName (ShrinkIt archive source)
|
|
|
|
|
|
|
|
+ after a file name indicates a GS/OS or Mac OS extended (forked) file.
|
|
|
|
Wildcard matching (*) is not supported and images are not validated.
|
|
|
|
ShrinkIt support requires Nulib2. cppo requires Python 2.6+ or 3.0+."""
|
|
|
|
|
|
|
|
# cppo by Ivan X, ivan@ivanx.com, ivanx.com/appleii
|
|
|
|
|
|
|
|
# Does anyone want to rewrite/refactor this? It works, but it's a mess.
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
import time
|
|
|
|
import datetime
|
|
|
|
import shutil
|
|
|
|
import errno
|
|
|
|
import uuid
|
|
|
|
import subprocess
|
|
|
|
import tempfile
|
2017-06-20 19:43:29 -07:00
|
|
|
from binascii import a2b_hex, b2a_hex
|
2017-06-20 19:27:38 -07:00
|
|
|
|
2017-06-20 19:48:22 -07:00
|
|
|
class Globals:
|
2017-06-20 19:27:38 -07:00
|
|
|
pass
|
|
|
|
|
|
|
|
g = Globals()
|
|
|
|
|
2017-06-22 01:33:40 -07:00
|
|
|
g.image_data = b''
|
|
|
|
g.out_data = bytearray(b'')
|
|
|
|
g.ex_data = None
|
2017-06-20 19:27:38 -07:00
|
|
|
|
|
|
|
g.activeDirBlock = None
|
|
|
|
g.activeFileName = None
|
|
|
|
g.activeFileSize = None
|
|
|
|
g.activeFileBytesCopied = 0
|
|
|
|
g.resourceFork = 0
|
|
|
|
g.shk_hasrf = False
|
|
|
|
|
|
|
|
g.PDOSPATH = []
|
|
|
|
g.PDOSPATH_INDEX = 0
|
|
|
|
g.PDOSPATH_SEGMENT = None
|
|
|
|
g.DIRPATH = ""
|
|
|
|
|
2017-06-22 02:30:05 -07:00
|
|
|
g.target_name = None
|
|
|
|
g.target_dir = ""
|
|
|
|
g.appledouble_dir = None
|
2017-06-22 01:33:40 -07:00
|
|
|
g.image_file = None
|
|
|
|
g.extract_file = None
|
2017-06-20 19:27:38 -07:00
|
|
|
|
|
|
|
# runtime options
|
2017-06-22 02:30:05 -07:00
|
|
|
g.use_appledouble = False # -ad (AppleDouble headers + resource forks)
|
|
|
|
g.use_extended = False # -e (extended filenames + resource forks)
|
|
|
|
g.catalog_only = False # -cat (catalog only, no extract)
|
|
|
|
g.casefold_upper = False # -uc (GS/OS mixed case filenames extract as uppercase)
|
|
|
|
g.src_shk = False # -shk (ShrinkIt archive source)
|
|
|
|
g.prodos_names = False # -pro (adapt DOS 3.3 names to ProDOS)
|
|
|
|
g.afpsync_msg = True # -s (sets False to suppress afpsync message at end)
|
|
|
|
g.extract_in_place = False # -n (don't create parent dir for SHK, extract files in place)
|
|
|
|
g.dos33 = False # (DOS 3.3 image source, selected automatically)
|
2017-06-20 19:27:38 -07:00
|
|
|
|
|
|
|
# functions
|
|
|
|
|
|
|
|
def pdosDateToUnixDate(arg1):
|
|
|
|
# input: ProDOS date/time bit sequence string in format:
|
|
|
|
# "yyyyyyymmmmddddd000hhhhh00mmmmmm" (ustr)
|
|
|
|
# output: seconds since Unix epoch (1-Jan-1970),
|
|
|
|
# or current date/time if no ProDOS date
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
year = to_dec(arg1[0:7]) + (1900 if year >= 1940 else 2000)
|
|
|
|
month = to_dec(arg1[sli(7,4)])
|
|
|
|
day = to_dec(arg1[sli(11,5)])
|
|
|
|
hour = to_dec(arg1[sli(19,5)])
|
|
|
|
minute = to_dec(arg1[sli(26,6)])
|
|
|
|
#print(year, month, day, hour, minute)
|
2017-06-20 19:27:38 -07:00
|
|
|
td = (datetime.datetime(year, month, day, hour, minute) -
|
|
|
|
datetime.datetime(1970,1,1))
|
|
|
|
unixDate_naive = (td.days*24*60*60 + td.seconds)
|
|
|
|
td2 = (datetime.datetime.fromtimestamp(unixDate_naive) -
|
|
|
|
datetime.datetime.utcfromtimestamp(unixDate_naive))
|
|
|
|
utcoffset = (td2.days*24*60*60 + td2.seconds)
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
#print(unixDate_naive - utcoffset)
|
2017-06-20 19:27:38 -07:00
|
|
|
return (unixDate_naive - utcoffset) # local time zone with DST
|
|
|
|
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
def unixDateToADDate(unix_date):
|
|
|
|
""" convert UNIX date to Apple epoch (2000-01-01) """
|
2017-06-20 19:27:38 -07:00
|
|
|
# input: seconds since Unix epoch (1-Jan-1970 00:00:00 GMT)
|
|
|
|
# output: seconds since Netatalk epoch (1-Jan-2000 00:00:00 GMT),
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
# in 4 bytes
|
|
|
|
adDate = (unix_date - 946684800)
|
|
|
|
# $ date --date="2000-01-01 00:00:00 GMT" +%s
|
|
|
|
# 946684800
|
|
|
|
#
|
|
|
|
# Think: "UNIX dates have 30 years too many seconds to be Apple dates,
|
|
|
|
# so we need to subtract 30 years' worth of seconds."
|
2017-06-22 04:17:23 -07:00
|
|
|
if adDate < 0:
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
adDate += 1<<32 # to get negative hex number
|
|
|
|
return adDate.to_bytes(4, 'big')
|
2017-06-20 19:27:38 -07:00
|
|
|
|
|
|
|
# cppo support functions:
|
|
|
|
# arg1: directory block or [T,S] containing file entry, or shk file dir path
|
|
|
|
# arg2: file index in overall directory (if applicable), or shk file name
|
|
|
|
|
|
|
|
# returns byte position in disk image file
|
|
|
|
def getStartPos(arg1, arg2):
|
2017-06-22 02:30:05 -07:00
|
|
|
if g.dos33:
|
2017-06-20 19:27:38 -07:00
|
|
|
return (ts(arg1) + (35 * (arg2 % 7)) + 11)
|
|
|
|
else: # ProDOS
|
|
|
|
return ( (arg1 * 512) +
|
|
|
|
(39 * ((arg2 + (arg2 > 11)) % 13)) +
|
2017-06-22 04:17:23 -07:00
|
|
|
(4 if arg2 > 11 else 43) )
|
2017-06-20 19:27:38 -07:00
|
|
|
|
|
|
|
def getStorageType(arg1, arg2):
|
|
|
|
start = getStartPos(arg1, arg2)
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
firstByte = g.image_data[start]
|
2017-06-22 02:30:05 -07:00
|
|
|
return (int(firstByte != 255)*2 if g.dos33 else (firstByte//16))
|
2017-06-20 19:27:38 -07:00
|
|
|
|
|
|
|
def getFileName(arg1, arg2):
|
|
|
|
start = getStartPos(arg1, arg2)
|
2017-06-22 02:30:05 -07:00
|
|
|
if g.dos33:
|
2017-06-20 19:27:38 -07:00
|
|
|
fileNameLo = bytearray()
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
fileNameHi = g.image_data[sli(start+3, 30)]
|
2017-06-20 19:27:38 -07:00
|
|
|
for b in fileNameHi:
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
fileNameLo.append(b & 0x7f)
|
2017-06-20 19:27:38 -07:00
|
|
|
fileName = bytes(fileNameLo).rstrip()
|
|
|
|
else: # ProDOS
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
firstByte = g.image_data[start]
|
|
|
|
entryType = firstByte//16
|
|
|
|
nameLength = firstByte - entryType*16
|
|
|
|
fileName = g.image_data[sli(start+1, nameLength)]
|
2017-06-20 19:27:38 -07:00
|
|
|
caseMask = getCaseMask(arg1, arg2)
|
2017-06-22 04:17:23 -07:00
|
|
|
if caseMask and not g.casefold_upper:
|
2017-06-22 04:37:34 -07:00
|
|
|
fileName = bytearray(fileName)
|
2017-06-20 19:27:38 -07:00
|
|
|
for i in range(0, len(fileName)):
|
2017-06-22 04:17:23 -07:00
|
|
|
if caseMask[i] == "1":
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
fileName[i:i+1] = fileName[i:i+1].lower()
|
2017-06-22 04:37:34 -07:00
|
|
|
fileName = bytes(fileName)
|
2017-06-20 19:27:38 -07:00
|
|
|
return fileName
|
|
|
|
|
|
|
|
def getCaseMask(arg1, arg2):
|
|
|
|
start = getStartPos(arg1, arg2)
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
caseMaskDec = int.from_bytes(g.image_data[sli(start+28,2)], 'little')
|
2017-06-22 04:17:23 -07:00
|
|
|
if caseMaskDec < 32768:
|
2017-06-20 19:27:38 -07:00
|
|
|
return None
|
|
|
|
else:
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
return to_bin(caseMaskDec - 32768, 15)
|
2017-06-20 19:27:38 -07:00
|
|
|
|
|
|
|
def getFileType(arg1, arg2):
|
2017-06-22 02:30:05 -07:00
|
|
|
if g.src_shk:
|
2017-06-20 19:27:38 -07:00
|
|
|
return arg2.split('#')[1][0:2]
|
|
|
|
start = getStartPos(arg1, arg2)
|
2017-06-22 02:30:05 -07:00
|
|
|
if g.dos33:
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
d33fileType = g.image_data[start+2]
|
2017-06-22 04:17:23 -07:00
|
|
|
if (d33fileType & 127) == 4:
|
2017-06-20 19:27:38 -07:00
|
|
|
return '06' # BIN
|
2017-06-22 04:17:23 -07:00
|
|
|
elif (d33fileType & 127) == 1:
|
2017-06-20 19:27:38 -07:00
|
|
|
return 'FA' # INT
|
2017-06-22 04:17:23 -07:00
|
|
|
elif (d33fileType & 127) == 2:
|
2017-06-20 19:27:38 -07:00
|
|
|
return 'FC' # BAS
|
|
|
|
else:
|
|
|
|
return '04' # TXT or other
|
|
|
|
else: # ProDOS
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
return b2a_hex(g.image_data[start+16:start+17]).decode()
|
2017-06-20 19:27:38 -07:00
|
|
|
|
|
|
|
def getAuxType(arg1, arg2):
|
2017-06-22 02:30:05 -07:00
|
|
|
if g.src_shk:
|
2017-06-20 19:27:38 -07:00
|
|
|
return arg2.split('#')[1][2:6]
|
|
|
|
start = getStartPos(arg1, arg2)
|
2017-06-22 02:30:05 -07:00
|
|
|
if g.dos33:
|
2017-06-20 19:27:38 -07:00
|
|
|
fileType = getFileType(arg1, arg2)
|
2017-06-22 04:17:23 -07:00
|
|
|
if fileType == '06': # BIN (B)
|
2017-06-20 19:27:38 -07:00
|
|
|
# file address is in first two bytes of file data
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
fileTSlist = list(g.image_data[sli(start+0,2)])
|
|
|
|
fileStart = list(g.image_data[sli(ts(fileTSlist)+12,2)])
|
|
|
|
return (b2a_hex(g.image_data[sli(ts(fileStart)+1,1)]) +
|
|
|
|
b2a_hex(g.image_data[sli(ts(fileStart),1)])).decode()
|
2017-06-22 04:17:23 -07:00
|
|
|
elif fileType == 'FC': # BAS (A)
|
2017-06-20 19:27:38 -07:00
|
|
|
return '0801'
|
2017-06-22 04:17:23 -07:00
|
|
|
elif fileType == 'FA': # INT (I)
|
2017-06-20 19:27:38 -07:00
|
|
|
return '9600'
|
|
|
|
else: # TXT (T) or other
|
|
|
|
return '0000'
|
|
|
|
else: # ProDOS
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
return (b2a_hex(g.image_data[sli(start+32,1)]) +
|
|
|
|
b2a_hex(g.image_data[sli(start+31,1)])).decode()
|
2017-06-20 19:27:38 -07:00
|
|
|
|
|
|
|
def getKeyPointer(arg1, arg2):
|
|
|
|
start = getStartPos(arg1, arg2)
|
2017-06-22 02:30:05 -07:00
|
|
|
if g.dos33:
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
return list(g.image_data[sli(start,2)])
|
2017-06-20 19:27:38 -07:00
|
|
|
else: # ProDOS
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
return int.from_bytes(g.image_data[sli(start+17,2)], 'little')
|
2017-06-20 19:27:38 -07:00
|
|
|
|
|
|
|
def getFileLength(arg1, arg2):
|
|
|
|
start = getStartPos(arg1, arg2)
|
2017-06-22 02:30:05 -07:00
|
|
|
if g.dos33:
|
2017-06-20 19:27:38 -07:00
|
|
|
fileType = getFileType(arg1, arg2)
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
fileTSlist = list(g.image_data[sli(start,2)])
|
|
|
|
fileStart = list(g.image_data[sli(ts(fileTSlist)+12,2)])
|
2017-06-22 04:17:23 -07:00
|
|
|
if fileType == '06': # BIN (B)
|
2017-06-20 19:27:38 -07:00
|
|
|
# file length is in second two bytes of file data
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
return (int.from_bytes(g.image_data[
|
|
|
|
sli(ts(fileStart)+2, 2)
|
|
|
|
], 'little') + 4)
|
2017-06-22 04:17:23 -07:00
|
|
|
elif fileType == 'FC' or fileType == 'FA': # BAS (A) or INT (I)
|
2017-06-20 19:27:38 -07:00
|
|
|
# file length is in first two bytes of file data
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
return (int.from_bytes(g.image_data[
|
|
|
|
sli(ts(fileStart), 2)
|
|
|
|
], 'little') + 2)
|
2017-06-20 19:27:38 -07:00
|
|
|
else: # TXT (T) or other
|
|
|
|
# sadly, we have to walk the whole file
|
|
|
|
# length is determined by sectors in TSlist, minus wherever
|
|
|
|
# anything after the first zero in the last sector
|
|
|
|
fileSize = 0
|
|
|
|
lastTSpair = None
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
prevTSpair = [0,0]
|
2017-06-20 19:27:38 -07:00
|
|
|
nextTSlistSector = fileTSlist
|
|
|
|
endFound = False
|
|
|
|
while not endFound:
|
|
|
|
pos = ts(nextTSlistSector)
|
|
|
|
for tsPos in range(12, 256, 2):
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
cur_ts_pair = list(g.image_data[sli(pos+tsPos,2)])
|
|
|
|
if ts(cur_ts_pair) != 0:
|
2017-06-20 19:27:38 -07:00
|
|
|
fileSize += 256
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
prevTSpair = cur_ts_pair
|
2017-06-20 19:27:38 -07:00
|
|
|
else:
|
|
|
|
lastTSpair = prevTSpair
|
|
|
|
endFound = True
|
|
|
|
break
|
|
|
|
if not lastTSpair:
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
nextTSlistSector = list(g.image_data[sli(pos+1,2)])
|
2017-06-22 04:17:23 -07:00
|
|
|
if nextTSlistSector[0]+nextTSlistSector[1] == 0:
|
2017-06-20 19:27:38 -07:00
|
|
|
lastTSpair = prevTSpair
|
|
|
|
endFound = True
|
|
|
|
break
|
|
|
|
fileSize -= 256
|
|
|
|
pos = ts(prevTSpair)
|
|
|
|
# now find out where the file really ends by finding the last 00
|
|
|
|
for offset in range(255, -1, -1):
|
|
|
|
#print("pos: " + to_hex(pos))
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
if g.image_data[pos+offset] != 0:
|
2017-06-20 19:27:38 -07:00
|
|
|
fileSize += (offset + 1)
|
|
|
|
break
|
|
|
|
return fileSize
|
|
|
|
else: # ProDOS
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
return int.from_bytes(g.image_data[sli(start+21,3)], 'little')
|
2017-06-20 19:27:38 -07:00
|
|
|
|
|
|
|
def getCreationDate(arg1, arg2):
|
|
|
|
#outputs prodos creation date/time as Unix time
|
|
|
|
# (seconds since Jan 1 1970 GMT)
|
|
|
|
#or None if there is none
|
2017-06-22 02:30:05 -07:00
|
|
|
if g.src_shk:
|
2017-06-20 19:27:38 -07:00
|
|
|
return None
|
2017-06-22 02:30:05 -07:00
|
|
|
elif g.dos33:
|
2017-06-20 19:27:38 -07:00
|
|
|
return None
|
|
|
|
else: # ProDOS
|
|
|
|
start = getStartPos(arg1, arg2)
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
pdosDate = (to_bin(g.image_data[start+25],8)+
|
|
|
|
to_bin(g.image_data[start+24],8)+
|
|
|
|
to_bin(g.image_data[start+27],8)+
|
|
|
|
to_bin(g.image_data[start+26],8))
|
2017-06-20 19:27:38 -07:00
|
|
|
try:
|
|
|
|
rVal = pdosDateToUnixDate(pdosDate)
|
|
|
|
except Exception:
|
|
|
|
rVal = None
|
|
|
|
return rVal
|
|
|
|
|
|
|
|
def getModifiedDate(arg1, arg2):
|
|
|
|
#outputs prodos modified date/time as Unix time
|
|
|
|
# (seconds since Jan 1 1970 GMT)
|
|
|
|
#or None if there is none
|
|
|
|
|
2017-06-22 02:30:05 -07:00
|
|
|
if g.src_shk:
|
2017-06-20 19:27:38 -07:00
|
|
|
modifiedDate = int(time.mktime(time.strptime(time.ctime(
|
|
|
|
os.path.getmtime(os.path.join(arg1, arg2))))))
|
|
|
|
rVal = modifiedDate
|
2017-06-22 02:30:05 -07:00
|
|
|
elif g.dos33:
|
2017-06-20 19:27:38 -07:00
|
|
|
rVal = None
|
|
|
|
else: # ProDOS
|
|
|
|
start = getStartPos(arg1, arg2)
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
pdosDate = (to_bin(g.image_data[start+34],8)+
|
|
|
|
to_bin(g.image_data[start+33],8)+
|
|
|
|
to_bin(g.image_data[start+36],8)+
|
|
|
|
to_bin(g.image_data[start+35],8))
|
2017-06-20 19:27:38 -07:00
|
|
|
try:
|
|
|
|
rVal = pdosDateToUnixDate(pdosDate)
|
|
|
|
except Exception:
|
|
|
|
rVal = None
|
|
|
|
return rVal
|
|
|
|
|
|
|
|
def getVolumeName():
|
|
|
|
return getWorkingDirName(2)
|
|
|
|
|
|
|
|
def getWorkingDirName(arg1, arg2=None):
|
|
|
|
# arg1:block, arg2:casemask (optional)
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
start = arg1 * 512
|
|
|
|
firstByte = g.image_data[start+4]
|
|
|
|
entryType = firstByte//16
|
|
|
|
nameLength = firstByte - entryType*16
|
|
|
|
workingDirName = g.image_data[sli(start+5, nameLength)]
|
2017-06-22 04:17:23 -07:00
|
|
|
if entryType == 15: # volume directory, get casemask from header
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
caseMaskDec = int.from_bytes(g.image_data[sli(start+26,2)], 'little')
|
2017-06-22 04:17:23 -07:00
|
|
|
if caseMaskDec < 32768:
|
2017-06-20 19:27:38 -07:00
|
|
|
caseMask = None
|
|
|
|
else:
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
caseMask = to_bin(caseMaskDec - 32768,15)
|
2017-06-20 19:27:38 -07:00
|
|
|
else: # subdirectory, get casemask from arg2 (not available in header)
|
|
|
|
caseMask = arg2
|
2017-06-22 04:37:34 -07:00
|
|
|
if caseMask and not g.casefold_upper:
|
|
|
|
workingDirName = bytearray(workingDirName)
|
2017-06-20 19:27:38 -07:00
|
|
|
for i in range(0, len(workingDirName)):
|
2017-06-22 04:17:23 -07:00
|
|
|
if caseMask[i] == "1":
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
workingDirName[i:i+1] = workingDirName[i:i+1].lower()
|
2017-06-22 04:37:34 -07:00
|
|
|
workingDirName = bytes(workingDirName)
|
2017-06-20 19:27:38 -07:00
|
|
|
return workingDirName
|
|
|
|
|
|
|
|
def getDirEntryCount(arg1):
|
2017-06-22 02:30:05 -07:00
|
|
|
if g.dos33:
|
2017-06-20 19:27:38 -07:00
|
|
|
entryCount = 0
|
|
|
|
nextSector = arg1
|
|
|
|
while True:
|
|
|
|
top = ts(nextSector)
|
|
|
|
pos = top+11
|
|
|
|
for e in range(0, 7):
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
if g.image_data[pos] == 0:
|
2017-06-20 19:27:38 -07:00
|
|
|
return entryCount # no more file entries
|
|
|
|
else:
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
if g.image_data[pos] != 255:
|
2017-06-20 19:27:38 -07:00
|
|
|
entryCount += 1 # increment if not deleted file
|
|
|
|
pos += 35
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
nextSector = list(g.image_data[sli(top+1,2)])
|
|
|
|
if nextSector == [0,0]: # no more catalog sectors
|
2017-06-20 19:27:38 -07:00
|
|
|
return entryCount
|
|
|
|
else: # ProDOS
|
2017-06-22 04:17:23 -07:00
|
|
|
start = arg1 * 512
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
return int.from_bytes(g.image_data[sli(start+37,2)], 'little')
|
2017-06-20 19:27:38 -07:00
|
|
|
|
|
|
|
def getDirNextChunkPointer(arg1):
|
2017-06-22 02:30:05 -07:00
|
|
|
if g.dos33:
|
2017-06-20 19:27:38 -07:00
|
|
|
start = ts(arg1)
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
return list(g.image_data[sli(start+1,2)])
|
2017-06-20 19:27:38 -07:00
|
|
|
else: # ProDOS
|
2017-06-22 04:17:23 -07:00
|
|
|
start = arg1 * 512
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
return int.from_bytes(g.image_data[sli(start+2,2)], 'little')
|
2017-06-20 19:27:38 -07:00
|
|
|
|
|
|
|
def toProdosName(name):
|
|
|
|
i=0
|
2017-06-22 04:17:23 -07:00
|
|
|
if name[0] == '.': # eliminate leading period
|
2017-06-20 19:27:38 -07:00
|
|
|
name = name[1:]
|
|
|
|
for c in name:
|
2017-06-22 04:17:23 -07:00
|
|
|
if c != '.' and not c.isalnum():
|
2017-06-20 19:27:38 -07:00
|
|
|
name = name[:i] + '.' + name[i+1:]
|
|
|
|
i+=1
|
2017-06-22 04:17:23 -07:00
|
|
|
name = name[:15]
|
2017-06-20 19:27:38 -07:00
|
|
|
return name
|
|
|
|
|
|
|
|
def ts(track, sector=None):
|
|
|
|
# returns offset; track and sector can be dec, or hex-ustr
|
|
|
|
# can also supply as [t,s] for convenience
|
2017-06-22 04:17:23 -07:00
|
|
|
if sector == None:
|
|
|
|
(track, sector) = track
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
if isinstance(track, str): # hex-ustr
|
2017-06-20 19:27:38 -07:00
|
|
|
track = int(track, 16)
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
if isinstance(sector, str): # hex-ustr
|
2017-06-20 19:27:38 -07:00
|
|
|
sector = int(sector, 16)
|
2017-06-22 04:17:23 -07:00
|
|
|
return track*16*256 + sector*256
|
2017-06-20 19:27:38 -07:00
|
|
|
|
2017-06-22 01:33:40 -07:00
|
|
|
def sli(start, length=1, ext=None):
|
|
|
|
"""return a slice object from an offset and length"""
|
|
|
|
return slice(start, start + length, ext)
|
|
|
|
|
2017-06-20 19:27:38 -07:00
|
|
|
# --- main logic functions
|
|
|
|
|
|
|
|
def copyFile(arg1, arg2):
|
|
|
|
#arg1/arg2:
|
|
|
|
# ProDOS : directory block / file index in overall directory
|
|
|
|
# DOS 3.3 : [track, sector] / file index in overall VTOC
|
|
|
|
# ShrinkIt: directory path / file name
|
2017-06-22 01:33:40 -07:00
|
|
|
# copies file or dfork to g.out_data, rfork if any to g.ex_data
|
2017-06-20 19:27:38 -07:00
|
|
|
g.activeFileBytesCopied = 0
|
|
|
|
|
2017-06-22 02:30:05 -07:00
|
|
|
if g.src_shk:
|
2017-06-20 19:27:38 -07:00
|
|
|
with open(os.path.join(arg1, arg2), 'rb') as infile:
|
2017-06-22 01:33:40 -07:00
|
|
|
g.out_data += infile.read()
|
2017-06-20 19:27:38 -07:00
|
|
|
if g.shk_hasrf:
|
|
|
|
print(" [data fork]")
|
2017-06-22 04:17:23 -07:00
|
|
|
if g.use_extended or g.use_appledouble:
|
2017-06-20 19:27:38 -07:00
|
|
|
print(" [resource fork]")
|
2017-06-22 04:17:23 -07:00
|
|
|
if g.ex_data == None:
|
2017-06-22 01:33:40 -07:00
|
|
|
g.ex_data = bytearray(b'')
|
2017-06-20 19:27:38 -07:00
|
|
|
with open(os.path.join(arg1, (arg2 + "r")), 'rb') as infile:
|
2017-06-22 01:33:40 -07:00
|
|
|
g.ex_data += infile.read()
|
2017-06-20 19:27:38 -07:00
|
|
|
else: # ProDOS or DOS 3.3
|
|
|
|
storageType = getStorageType(arg1, arg2)
|
|
|
|
keyPointer = getKeyPointer(arg1, arg2)
|
|
|
|
fileLen = getFileLength(arg1, arg2)
|
2017-06-22 04:17:23 -07:00
|
|
|
if storageType == 1: #seedling
|
2017-06-20 19:27:38 -07:00
|
|
|
copyBlock(keyPointer, fileLen)
|
2017-06-22 04:17:23 -07:00
|
|
|
elif storageType == 2: #sapling
|
2017-06-20 19:27:38 -07:00
|
|
|
processIndexBlock(keyPointer)
|
2017-06-22 04:17:23 -07:00
|
|
|
elif storageType == 3: #tree
|
2017-06-20 19:27:38 -07:00
|
|
|
processMasterIndexBlock(keyPointer)
|
2017-06-22 04:17:23 -07:00
|
|
|
elif storageType == 5: #extended (forked)
|
2017-06-20 19:27:38 -07:00
|
|
|
processForkedFile(keyPointer)
|
2017-06-22 02:30:05 -07:00
|
|
|
if g.prodos_names:
|
2017-06-20 19:27:38 -07:00
|
|
|
# remove address/length data from DOS 3.3 file data if ProDOS target
|
2017-06-22 04:17:23 -07:00
|
|
|
if getFileType(arg1, arg2) == '06':
|
2017-06-22 01:33:40 -07:00
|
|
|
g.out_data = g.out_data[4:]
|
2017-06-22 04:17:23 -07:00
|
|
|
elif (getFileType(arg1, arg2) == 'FA' or
|
2017-06-20 19:27:38 -07:00
|
|
|
getFileType(arg1, arg2) == 'FC'):
|
2017-06-22 01:33:40 -07:00
|
|
|
g.out_data = g.out_data[2:]
|
2017-06-20 19:27:38 -07:00
|
|
|
|
|
|
|
def copyBlock(arg1, arg2):
|
|
|
|
#arg1: block number or [t,s] to copy
|
|
|
|
#arg2: bytes to write (should be 256 (DOS 3.3) or 512 (ProDOS),
|
|
|
|
# unless final block with less)
|
|
|
|
#print(arg1 + " " + arg2 + " " + g.activeFileBytesCopied)
|
2017-06-22 04:17:23 -07:00
|
|
|
if arg1 == 0:
|
|
|
|
outBytes = bytes(arg2)
|
2017-06-20 19:27:38 -07:00
|
|
|
else:
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
outBytes = g.image_data[sli(ts(arg1) if g.dos33 else arg1*512, arg2)]
|
2017-06-22 04:17:23 -07:00
|
|
|
if g.resourceFork > 0:
|
2017-06-22 02:30:05 -07:00
|
|
|
if g.use_appledouble or g.use_extended:
|
|
|
|
offset = (741 if g.use_appledouble else 0)
|
2017-06-22 04:17:23 -07:00
|
|
|
if g.ex_data == None:
|
2017-06-22 01:33:40 -07:00
|
|
|
g.ex_data = bytearray(b'')
|
|
|
|
g.ex_data[ (g.activeFileBytesCopied + offset) :
|
2017-06-20 19:27:38 -07:00
|
|
|
(g.activeFileBytesCopied + offset + arg2) ] = outBytes
|
|
|
|
else:
|
2017-06-22 01:33:40 -07:00
|
|
|
g.out_data[ g.activeFileBytesCopied :
|
2017-06-20 19:27:38 -07:00
|
|
|
(g.activeFileBytesCopied + arg2) ] = outBytes
|
|
|
|
g.activeFileBytesCopied += arg2
|
|
|
|
|
|
|
|
def processDir(arg1, arg2=None, arg3=None, arg4=None, arg5=None):
|
|
|
|
# arg1: ProDOS directory block, or DOS 3.3 [track,sector]
|
|
|
|
# for key block (with directory header):
|
|
|
|
# arg2: casemask (optional), arg3:None, arg4:None, arg5:None
|
|
|
|
# for secondary directory blocks (non-key block):
|
|
|
|
# arg2/3/4/5: for non-key chunks: entryCount, entry#,
|
|
|
|
# workingDirName, processedEntryCount
|
|
|
|
|
|
|
|
entryCount = None
|
|
|
|
e = None
|
|
|
|
pe = None
|
|
|
|
workingDirName = None
|
|
|
|
|
|
|
|
if arg3:
|
|
|
|
entryCount = arg2
|
|
|
|
e = arg3
|
|
|
|
workingDirName = arg4
|
|
|
|
pe = arg5
|
|
|
|
else:
|
|
|
|
e = 0
|
|
|
|
pe = 0
|
|
|
|
entryCount = getDirEntryCount(arg1)
|
2017-06-22 02:30:05 -07:00
|
|
|
if not g.dos33:
|
2017-06-20 19:27:38 -07:00
|
|
|
workingDirName = getWorkingDirName(arg1, arg2).decode("L1")
|
|
|
|
g.DIRPATH = (g.DIRPATH + "/" + workingDirName)
|
|
|
|
if g.PDOSPATH_INDEX:
|
2017-06-22 04:17:23 -07:00
|
|
|
if g.PDOSPATH_INDEX == 1:
|
|
|
|
if ("/" + g.PDOSPATH_SEGMENT.lower()) != g.DIRPATH.lower():
|
2017-06-20 19:27:38 -07:00
|
|
|
print("ProDOS volume name does not match disk image.")
|
|
|
|
quitNow(2)
|
|
|
|
else:
|
|
|
|
g.PDOSPATH_INDEX += 1
|
|
|
|
g.PDOSPATH_SEGMENT = g.PDOSPATH[g.PDOSPATH_INDEX]
|
2017-06-20 19:49:40 -07:00
|
|
|
#else: print(g.DIRPATH)
|
2017-06-22 04:17:23 -07:00
|
|
|
while pe < entryCount:
|
|
|
|
if getStorageType(arg1, e) > 0:
|
2017-06-20 19:27:38 -07:00
|
|
|
#print(pe, e, entryCount)
|
|
|
|
processEntry(arg1, e)
|
|
|
|
pe += 1
|
|
|
|
e += 1
|
2017-06-22 04:17:23 -07:00
|
|
|
if not (e + (0 if g.dos33 else (e>11)) ) % (7 if g.dos33 else 13):
|
2017-06-20 19:27:38 -07:00
|
|
|
processDir(getDirNextChunkPointer(arg1), entryCount, e,
|
|
|
|
workingDirName, pe)
|
|
|
|
break
|
|
|
|
|
|
|
|
def processEntry(arg1, arg2):
|
2017-06-22 02:30:05 -07:00
|
|
|
# arg1=block number, [t,s] if g.dos33=True, or subdir name if g.src_shk=1
|
|
|
|
# arg2=index number of entry in directory, or file name if g.src_shk=1
|
2017-06-20 19:27:38 -07:00
|
|
|
|
|
|
|
#print(getFileName(arg1, arg2), getStorageType(arg1, arg2),
|
|
|
|
# getFileType(arg1, arg2), getKeyPointer(arg1, arg2),
|
|
|
|
# getFileLength(arg1, arg2), getAuxType(arg1, arg2),
|
|
|
|
# getCreationDate(arg1, arg2), getModifiedDate(arg1, arg2))
|
|
|
|
|
|
|
|
eTargetName = None
|
2017-06-22 01:33:40 -07:00
|
|
|
g.ex_data = None
|
|
|
|
g.out_data = bytearray(b'')
|
2017-06-22 02:30:05 -07:00
|
|
|
if g.src_shk: # ShrinkIt archive
|
|
|
|
g.activeFileName = (arg2 if g.use_extended else arg2.split('#')[0])
|
|
|
|
if g.casefold_upper:
|
2017-06-20 19:27:38 -07:00
|
|
|
g.activeFileName = g.activeFileName.upper()
|
|
|
|
origFileName = g.activeFileName
|
|
|
|
else: # ProDOS or DOS 3.3 image
|
|
|
|
g.activeFileName = getFileName(arg1 ,arg2).decode("L1")
|
|
|
|
origFileName = g.activeFileName
|
2017-06-22 02:30:05 -07:00
|
|
|
if g.prodos_names:
|
2017-06-20 19:27:38 -07:00
|
|
|
g.activeFileName = toProdosName(g.activeFileName)
|
|
|
|
g.activeFileSize = getFileLength(arg1, arg2)
|
|
|
|
|
|
|
|
if (not g.PDOSPATH_INDEX or
|
|
|
|
g.activeFileName.upper() == g.PDOSPATH_SEGMENT.upper()):
|
|
|
|
|
|
|
|
# if ProDOS directory, not file
|
2017-06-22 04:17:23 -07:00
|
|
|
if not g.src_shk and getStorageType(arg1, arg2) == 13:
|
2017-06-20 19:27:38 -07:00
|
|
|
if not g.PDOSPATH_INDEX:
|
2017-06-22 04:17:23 -07:00
|
|
|
g.target_dir = g.target_dir + "/" + g.activeFileName
|
|
|
|
g.appledouble_dir = g.target_dir + "/.AppleDouble"
|
|
|
|
if not g.catalog_only or os.path.isdir(g.target_dir):
|
2017-06-22 02:30:05 -07:00
|
|
|
makedirs(g.target_dir)
|
2017-06-22 04:17:23 -07:00
|
|
|
if (not g.catalog_only and g.use_appledouble and
|
|
|
|
not os.path.isdir(g.appledouble_dir)):
|
2017-06-22 02:30:05 -07:00
|
|
|
makedirs(g.appledouble_dir)
|
2017-06-20 19:27:38 -07:00
|
|
|
if g.PDOSPATH_SEGMENT:
|
|
|
|
g.PDOSPATH_INDEX += 1
|
|
|
|
g.PDOSPATH_SEGMENT = g.PDOSPATH[g.PDOSPATH_INDEX]
|
|
|
|
processDir(getKeyPointer(arg1, arg2), getCaseMask(arg1, arg2))
|
|
|
|
g.DIRPATH = g.DIRPATH.rsplit("/", 1)[0]
|
|
|
|
if not g.PDOSPATH_INDEX:
|
2017-06-22 02:30:05 -07:00
|
|
|
g.target_dir = g.target_dir.rsplit("/", 1)[0]
|
|
|
|
g.appledouble_dir = (g.target_dir + "/.AppleDouble")
|
2017-06-20 19:27:38 -07:00
|
|
|
else: # ProDOS or DOS 3.3 file either from image or ShrinkIt archive
|
|
|
|
dirPrint = ""
|
|
|
|
if g.DIRPATH:
|
|
|
|
dirPrint = g.DIRPATH + "/"
|
|
|
|
else:
|
2017-06-22 02:30:05 -07:00
|
|
|
if g.src_shk:
|
2017-06-22 04:17:23 -07:00
|
|
|
if "/".join(dirName.split('/')[3:]):
|
2017-06-20 19:27:38 -07:00
|
|
|
dirPrint = ("/".join(dirName.split('/')[3:]) + "/")
|
2017-06-22 01:33:40 -07:00
|
|
|
if (not g.extract_file or
|
|
|
|
(os.path.basename(g.extract_file.lower()) ==
|
2017-06-20 19:27:38 -07:00
|
|
|
origFileName.split('#')[0].lower())):
|
|
|
|
filePrint = g.activeFileName.split("#")[0]
|
|
|
|
print(dirPrint + filePrint +
|
|
|
|
("+" if (g.shk_hasrf or
|
2017-06-22 02:30:05 -07:00
|
|
|
(not g.src_shk and getStorageType(arg1, arg2) == 5))
|
2017-06-20 19:27:38 -07:00
|
|
|
else "") +
|
|
|
|
((" [" + origFileName + "] ")
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
if (g.prodos_names and
|
|
|
|
(origFileName != g.activeFileName))
|
2017-06-20 19:27:38 -07:00
|
|
|
else ""))
|
2017-06-22 02:30:05 -07:00
|
|
|
if g.catalog_only:
|
2017-06-20 19:27:38 -07:00
|
|
|
return
|
2017-06-22 02:30:05 -07:00
|
|
|
if not g.target_name:
|
|
|
|
g.target_name = g.activeFileName
|
|
|
|
if g.use_extended:
|
|
|
|
if g.src_shk:
|
2017-06-20 19:27:38 -07:00
|
|
|
eTargetName = arg2
|
|
|
|
else: # ProDOS image
|
2017-06-22 02:30:05 -07:00
|
|
|
eTargetName = (g.target_name + "#" +
|
2017-06-20 19:27:38 -07:00
|
|
|
getFileType(arg1, arg2).lower() +
|
|
|
|
getAuxType(arg1, arg2).lower())
|
2017-06-22 02:30:05 -07:00
|
|
|
# touch(g.target_dir + "/" + g.target_name)
|
|
|
|
if g.use_appledouble:
|
2017-06-20 19:27:38 -07:00
|
|
|
makeADfile()
|
|
|
|
copyFile(arg1, arg2)
|
2017-06-22 02:30:05 -07:00
|
|
|
saveName = (g.target_dir + "/" +
|
|
|
|
(eTargetName if eTargetName else g.target_name))
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
save_file(saveName, g.out_data)
|
2017-06-20 19:27:38 -07:00
|
|
|
creationDate = getCreationDate(arg1, arg2)
|
|
|
|
modifiedDate = getModifiedDate(arg1, arg2)
|
2017-06-22 04:17:23 -07:00
|
|
|
if modifiedDate and not creationDate:
|
2017-06-20 19:27:38 -07:00
|
|
|
creationDate = modifiedDate
|
2017-06-22 04:17:23 -07:00
|
|
|
elif creationDate and not modifiedDate:
|
2017-06-20 19:27:38 -07:00
|
|
|
modifiedDate = creationDate
|
2017-06-22 04:17:23 -07:00
|
|
|
elif not creationDate and not modifiedDate:
|
2017-06-20 19:27:38 -07:00
|
|
|
creationDate = (datetime.datetime.today() -
|
|
|
|
datetime.datetime(1970,1,1)).days*24*60*60
|
|
|
|
modifiedDate = creationDate
|
2017-06-22 02:30:05 -07:00
|
|
|
if g.use_appledouble: # AppleDouble
|
2017-06-20 19:27:38 -07:00
|
|
|
# set dates
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
ADfile_path = g.appledouble_dir + "/" + g.target_name
|
|
|
|
g.ex_data[637:641] = unixDateToADDate(creationDate)
|
|
|
|
g.ex_data[641:645] = unixDateToADDate(modifiedDate)
|
|
|
|
g.ex_data[645] = 0x80
|
|
|
|
g.ex_data[649] = 0x80
|
2017-06-20 19:27:38 -07:00
|
|
|
#set type/creator
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
g.ex_data[653] = ord('p')
|
|
|
|
g.ex_data[654:657] = bytes.fromhex(
|
2017-06-20 19:27:38 -07:00
|
|
|
getFileType(arg1, arg2) +
|
|
|
|
getAuxType(arg1, arg2))
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
g.ex_data[657:661] = b'pdos'
|
|
|
|
save_file(ADfile_path, g.ex_data)
|
2017-06-20 19:27:38 -07:00
|
|
|
touch(saveName, modifiedDate)
|
2017-06-22 02:30:05 -07:00
|
|
|
if g.use_extended: # extended name from ProDOS image
|
2017-06-22 04:17:23 -07:00
|
|
|
if g.ex_data:
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
save_file((saveName + "r"), g.ex_data)
|
2017-06-20 19:27:38 -07:00
|
|
|
touch((saveName + "r"), modifiedDate)
|
|
|
|
if (g.PDOSPATH_SEGMENT or
|
2017-06-22 01:33:40 -07:00
|
|
|
(g.extract_file and
|
|
|
|
(g.extract_file.lower() == origFileName.lower()))):
|
2017-06-20 19:27:38 -07:00
|
|
|
quitNow(0)
|
2017-06-22 02:30:05 -07:00
|
|
|
g.target_name = None
|
2017-06-22 04:17:23 -07:00
|
|
|
#else print(g.activeFileName + " doesn't match " + g.PDOSPATH_SEGMENT)
|
2017-06-20 19:27:38 -07:00
|
|
|
|
|
|
|
def processForkedFile(arg1):
|
|
|
|
# finder info except type/creator
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
fInfoA_entryType = g.image_data[9]
|
|
|
|
fInfoB_entryType = g.image_data[27]
|
2017-06-22 04:17:23 -07:00
|
|
|
if fInfoA_entryType == 1:
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
g.image_data[661:669], g.image_data[18:26]
|
2017-06-22 04:17:23 -07:00
|
|
|
elif fInfoA_entryType == 2:
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
g.image_data[669:685], g.image_data[10:26]
|
2017-06-22 04:17:23 -07:00
|
|
|
if fInfoB_entryType == 1:
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
g.image_data[661:669], g.image_data[36:44]
|
2017-06-22 04:17:23 -07:00
|
|
|
elif fInfoB_entryType == 2:
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
g.image_data[669:685], g.image_data[28:44]
|
2017-06-20 19:27:38 -07:00
|
|
|
|
2017-06-22 04:17:23 -07:00
|
|
|
for f in (0, 256):
|
2017-06-20 19:27:38 -07:00
|
|
|
g.resourceFork = f
|
|
|
|
g.activeFileBytesCopied = 0
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
forkStart = arg1 * 512 # start of Forked File key block
|
|
|
|
#print("--" + forkStart)
|
|
|
|
forkStorageType = g.image_data[forkStart+f]
|
|
|
|
forkKeyPointer = int.from_bytes(g.image_data[
|
|
|
|
sli(forkStart+f+1,2) ], 'little')
|
|
|
|
forkFileLen = int.from_bytes(g.image_data[
|
|
|
|
sli(forkStart+f+5,3) ], 'little')
|
2017-06-20 19:27:38 -07:00
|
|
|
g.activeFileSize = forkFileLen
|
2017-06-22 04:17:23 -07:00
|
|
|
if g.resourceFork > 0:
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
rsrcForkLen = int.from_bytes(g.image_data[
|
|
|
|
sli(forkStart + f + 5, 3)],'little')
|
|
|
|
#print(">>>", rsrcForkLen)
|
2017-06-22 04:17:23 -07:00
|
|
|
if g.use_appledouble or g.use_extended:
|
2017-06-20 19:27:38 -07:00
|
|
|
print(" [resource fork]")
|
2017-06-22 02:30:05 -07:00
|
|
|
if g.use_appledouble:
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
g.ex_data[35:38] = rsrcForkLen.to_bytes(3, 'big')
|
2017-06-20 19:27:38 -07:00
|
|
|
else:
|
|
|
|
print(" [data fork]")
|
2017-06-22 04:17:23 -07:00
|
|
|
if forkStorageType == 1: #seedling
|
2017-06-20 19:27:38 -07:00
|
|
|
copyBlock(forkKeyPointer, forkFileLen)
|
2017-06-22 04:17:23 -07:00
|
|
|
elif forkStorageType == 2: #sapling
|
2017-06-20 19:27:38 -07:00
|
|
|
processIndexBlock(forkKeyPointer)
|
2017-06-22 04:17:23 -07:00
|
|
|
elif forkStorageType == 3: #tree
|
2017-06-20 19:27:38 -07:00
|
|
|
processMasterIndexBlock(forkKeyPointer)
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
#print()
|
2017-06-20 19:27:38 -07:00
|
|
|
g.resourceFork = 0
|
|
|
|
|
|
|
|
def processMasterIndexBlock(arg1):
|
|
|
|
processIndexBlock(arg1, True)
|
|
|
|
|
|
|
|
def processIndexBlock(arg1, arg2=False):
|
|
|
|
#arg1: indexBlock, or [t,s] of track/sector list
|
|
|
|
#arg2: if True, it's a Master Index Block
|
2017-06-22 02:30:05 -07:00
|
|
|
pos = 12 if g.dos33 else 0
|
2017-06-20 19:27:38 -07:00
|
|
|
bytesRemaining = g.activeFileSize
|
2017-06-22 04:17:23 -07:00
|
|
|
while g.activeFileBytesCopied < g.activeFileSize:
|
2017-06-22 02:30:05 -07:00
|
|
|
if g.dos33:
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
targetTS = list(g.image_data[sli(ts(arg1)+pos,2)])
|
2017-06-20 19:27:38 -07:00
|
|
|
#print(to_hex(targetTS[0]),to_hex(targetTS[1]))
|
|
|
|
bytesRemaining = (g.activeFileSize - g.activeFileBytesCopied)
|
2017-06-22 04:17:23 -07:00
|
|
|
bs = (bytesRemaining if bytesRemaining < 256 else 256)
|
2017-06-20 19:27:38 -07:00
|
|
|
copyBlock(targetTS, bs)
|
|
|
|
pos += 2
|
2017-06-22 04:17:23 -07:00
|
|
|
if pos > 255:
|
2017-06-20 19:27:38 -07:00
|
|
|
# continue with next T/S list sector
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
processIndexBlock(list(g.image_data[sli(ts(arg1)+1,2)]))
|
2017-06-20 19:27:38 -07:00
|
|
|
else: # ProDOS
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
# Note these are not consecutive bytes
|
|
|
|
targetBlock = (g.image_data[arg1*512+pos] +
|
|
|
|
g.image_data[arg1*512+pos+256]*256)
|
2017-06-20 19:27:38 -07:00
|
|
|
if arg2:
|
|
|
|
processIndexBlock(targetBlock)
|
|
|
|
else:
|
|
|
|
bytesRemaining = (g.activeFileSize - g.activeFileBytesCopied)
|
2017-06-22 04:17:23 -07:00
|
|
|
bs = (bytesRemaining if bytesRemaining < 512 else 512)
|
2017-06-20 19:27:38 -07:00
|
|
|
copyBlock(targetBlock, bs)
|
|
|
|
pos += 1
|
2017-06-22 04:17:23 -07:00
|
|
|
if pos > 255:
|
2017-06-20 19:27:38 -07:00
|
|
|
break # go to next entry in Master Index Block (tree)
|
|
|
|
|
|
|
|
def makeADfile():
|
2017-06-22 02:30:05 -07:00
|
|
|
if not g.use_appledouble:
|
2017-06-20 19:27:38 -07:00
|
|
|
return
|
2017-06-22 02:30:05 -07:00
|
|
|
touch(g.appledouble_dir + "/" + g.target_name)
|
2017-06-22 01:33:40 -07:00
|
|
|
g.ex_data = bytearray(741)
|
2017-06-20 19:27:38 -07:00
|
|
|
# ADv2 header
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
g.ex_data[sli(0x00,8)] = a2b_hex("0005160700020000")
|
2017-06-20 19:27:38 -07:00
|
|
|
# number of entries
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
g.ex_data[sli(0x18,2)] = a2b_hex("000D")
|
2017-06-20 19:27:38 -07:00
|
|
|
# Resource Fork
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
g.ex_data[sli(0x1a,12)] = a2b_hex("00000002000002E500000000")
|
2017-06-20 19:27:38 -07:00
|
|
|
# Real Name
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
g.ex_data[sli(0x26,12)] = a2b_hex("00000003000000B600000000")
|
2017-06-20 19:27:38 -07:00
|
|
|
# Comment
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
g.ex_data[sli(0x32,12)] = a2b_hex("00000004000001B500000000")
|
2017-06-20 19:27:38 -07:00
|
|
|
# Dates Info
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
g.ex_data[sli(0x3e,12)] = a2b_hex("000000080000027D00000010")
|
2017-06-20 19:27:38 -07:00
|
|
|
# Finder Info
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
g.ex_data[sli(0x4a,12)] = a2b_hex("000000090000028D00000020")
|
2017-06-20 19:27:38 -07:00
|
|
|
# ProDOS file info
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
g.ex_data[sli(0x56,12)] = a2b_hex("0000000B000002C100000008")
|
2017-06-20 19:27:38 -07:00
|
|
|
# AFP short name
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
g.ex_data[sli(0x62,12)] = a2b_hex("0000000D000002B500000000")
|
2017-06-20 19:27:38 -07:00
|
|
|
# AFP File Info
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
g.ex_data[sli(0x6e,12)] = a2b_hex("0000000E000002B100000004")
|
2017-06-20 19:27:38 -07:00
|
|
|
# AFP Directory ID
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
g.ex_data[sli(0x7a,12)] = a2b_hex("0000000F000002AD00000004")
|
2017-06-20 19:27:38 -07:00
|
|
|
# dbd (second time) will create DEV, INO, SYN, SV~
|
|
|
|
|
2017-06-22 01:33:40 -07:00
|
|
|
def quitNow(exitcode=0):
|
2017-06-22 02:30:05 -07:00
|
|
|
if (exitcode == 0 and g.afpsync_msg and
|
|
|
|
g.use_appledouble and os.path.isdir("/usr/local/etc/netatalk")):
|
2017-06-20 19:27:38 -07:00
|
|
|
print("File(s) have been copied to the target directory. " +
|
|
|
|
"If the directory")
|
|
|
|
print("is shared by Netatalk, please type 'afpsync' now.")
|
2017-06-22 02:30:05 -07:00
|
|
|
if g.src_shk: # clean up
|
2017-06-20 19:27:38 -07:00
|
|
|
for file in os.listdir('/tmp'):
|
|
|
|
if file.startswith("cppo-"):
|
|
|
|
shutil.rmtree('/tmp' + "/" + file)
|
2017-06-22 01:33:40 -07:00
|
|
|
sys.exit(exitcode)
|
2017-06-20 19:27:38 -07:00
|
|
|
|
|
|
|
def usage(exitcode=1):
|
|
|
|
print(sys.modules[__name__].__doc__)
|
|
|
|
quitNow(exitcode)
|
|
|
|
|
2017-06-21 05:50:22 -07:00
|
|
|
def to_sys_name(name):
|
|
|
|
if os.name == 'nt':
|
|
|
|
if name[-1] == '.':
|
|
|
|
name += '-'
|
|
|
|
name = name.replace('./', '.-/')
|
|
|
|
return name
|
|
|
|
|
2017-06-20 19:27:38 -07:00
|
|
|
#---- IvanX general purpose functions ----#
|
|
|
|
|
|
|
|
def to_hex(val):
|
|
|
|
"""convert bytes, decimal number, or [bin-ustr] to two-digit hex values
|
|
|
|
unlike hex(), accepts bytes; has no leading 0x or trailing L"""
|
|
|
|
if isinstance(val, list): # [bin-ustr]
|
|
|
|
val = int(val[0], 2)
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
|
2017-06-20 19:27:38 -07:00
|
|
|
if isinstance(val, bytes): # bytes
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
return b2a_hex(val).decode()
|
2017-06-20 19:27:38 -07:00
|
|
|
elif isnumber(val):
|
2017-06-22 04:17:23 -07:00
|
|
|
if val < 0:
|
2017-06-20 19:27:38 -07:00
|
|
|
print ("val: " + str(val))
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
return b2a_hex(bytes([val])).decode()
|
2017-06-20 19:27:38 -07:00
|
|
|
else:
|
|
|
|
raise Exception("to_hex() requires bytes, int/long, or [bin-ustr]")
|
|
|
|
|
|
|
|
def to_dec(val):
|
|
|
|
"""convert bytes, hex-ustr or [bin-ustr] to decimal int/long"""
|
|
|
|
if isinstance(val, list): # [bin-ustr]
|
|
|
|
return int(val[0], 2)
|
|
|
|
elif isinstance(val, bytes): # bytes
|
|
|
|
return int(to_hex(val), 16)
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
elif isinstance(val, str): # hex-ustr
|
2017-06-20 19:27:38 -07:00
|
|
|
return int(val, 16)
|
|
|
|
elif isnumber(val): # int/long
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
return val
|
2017-06-20 19:27:38 -07:00
|
|
|
else:
|
|
|
|
raise Exception("to_dec() requires bytes, hex-ustr or [bin-ustr]")
|
|
|
|
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
def to_bin(val, fill = None):
|
2017-06-20 19:27:38 -07:00
|
|
|
"""convert bytes, hex-ustr, or int/long to bin-ustr"""
|
|
|
|
if isinstance(val, bytes): # bytes
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
b = bin(to_dec(to_hex(val)))[2:]
|
|
|
|
elif isinstance(val, str): # hex-ustr
|
|
|
|
b = bin(int(val, 16))[2:]
|
2017-06-20 19:27:38 -07:00
|
|
|
elif isnumber(val): # int/long
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
b = bin(val)[2:]
|
2017-06-20 19:27:38 -07:00
|
|
|
else:
|
|
|
|
raise Exception("to_bin() requires bytes, hex-ustr, or int/long")
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
return b if not fill else b.zfill(fill)
|
2017-06-20 19:27:38 -07:00
|
|
|
|
|
|
|
def to_bytes(val):
|
|
|
|
"""converts hex-ustr, int/long, or [bin-ustr] to bytes"""
|
|
|
|
if isinstance(val, list): # [bin-ustr]
|
|
|
|
val = to_hex(val[0])
|
|
|
|
if isnumber(val): # int/long
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
if val < 256:
|
|
|
|
return chr(val).encode()
|
|
|
|
else:
|
|
|
|
val = to_hex(val)
|
|
|
|
|
|
|
|
if isinstance(val, str): # hex-ustr
|
|
|
|
return a2b_hex(val.encode())
|
|
|
|
elif isinstance(val, bytes):
|
2017-06-20 19:27:38 -07:00
|
|
|
return val
|
|
|
|
else:
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
raise Exception("to_bytes() requires hex-ustr, int/long, or [bin-ustr]")
|
2017-06-20 19:27:38 -07:00
|
|
|
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
def touch(file_path, modTime=None):
|
2017-06-20 19:27:38 -07:00
|
|
|
# http://stackoverflow.com/questions/1158076/implement-touch-using-python
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
#print(file_path)
|
|
|
|
with open(to_sys_name(file_path), "ab"):
|
|
|
|
os.utime(file_path, None if modTime is None else (modTime, modTime))
|
2017-06-20 19:27:38 -07:00
|
|
|
|
|
|
|
def mkdir(dirPath):
|
|
|
|
try:
|
2017-06-21 05:50:22 -07:00
|
|
|
os.mkdir(to_sys_name(dirPath))
|
2017-06-20 19:27:38 -07:00
|
|
|
except FileExistsError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def makedirs(dirPath):
|
|
|
|
try:
|
2017-06-21 05:50:22 -07:00
|
|
|
os.makedirs(to_sys_name(dirPath))
|
2017-06-20 19:27:38 -07:00
|
|
|
except OSError as e:
|
2017-06-22 04:17:23 -07:00
|
|
|
if e.errno != errno.EEXIST:
|
2017-06-20 19:27:38 -07:00
|
|
|
raise
|
|
|
|
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
def load_file(file_path):
|
|
|
|
with open(to_sys_name(file_path), "rb") as imageHandle:
|
2017-06-20 19:27:38 -07:00
|
|
|
return imageHandle.read()
|
|
|
|
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
def save_file(file_path, fileData):
|
|
|
|
with open(to_sys_name(file_path), "wb") as imageHandle:
|
2017-06-20 19:27:38 -07:00
|
|
|
imageHandle.write(fileData)
|
|
|
|
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
def dopo_swap(image_data):
|
|
|
|
# for each track,
|
|
|
|
# read each sector in the right sequence to make
|
|
|
|
# valid ProDOS blocks (sector pairs)
|
|
|
|
dopo = bytearray(143360)
|
|
|
|
for t in range(0, 35):
|
|
|
|
for s in range(16):
|
|
|
|
src = ts(t,s)
|
|
|
|
dst = ts(t,s if s in (0,15) else 15-s)
|
|
|
|
dopo[dst:dst+256] = image_data[src:src+256]
|
|
|
|
return bytes(dopo)
|
|
|
|
|
2017-06-20 19:27:38 -07:00
|
|
|
def isnumber(number):
|
|
|
|
try: # make sure it's not a string
|
|
|
|
len(number)
|
|
|
|
return False
|
|
|
|
except TypeError:
|
|
|
|
pass
|
|
|
|
try:
|
|
|
|
int(number)
|
|
|
|
except ValueError:
|
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
|
|
|
#---- end IvanX general purpose functions ----#
|
|
|
|
|
|
|
|
|
|
|
|
# --- start
|
2017-06-22 01:59:07 -07:00
|
|
|
if __name__ == '__main__':
|
|
|
|
args = sys.argv
|
2017-06-20 19:27:38 -07:00
|
|
|
|
2017-06-22 01:59:07 -07:00
|
|
|
while True: # breaks when there are no more arguments starting with dash
|
|
|
|
if len(args) == 1:
|
|
|
|
usage()
|
2017-06-20 19:27:38 -07:00
|
|
|
|
2017-06-22 04:17:23 -07:00
|
|
|
elif args[1][0] != '-':
|
2017-06-22 01:59:07 -07:00
|
|
|
break
|
2017-06-20 19:27:38 -07:00
|
|
|
|
2017-06-22 04:17:23 -07:00
|
|
|
elif args[1] == '-s':
|
2017-06-22 02:30:05 -07:00
|
|
|
g.afpsync_msg = False
|
2017-06-22 01:59:07 -07:00
|
|
|
args = args[1:]
|
2017-06-20 19:27:38 -07:00
|
|
|
|
2017-06-22 01:59:07 -07:00
|
|
|
elif args[1] == '-n':
|
2017-06-22 02:30:05 -07:00
|
|
|
g.extract_in_place = True
|
2017-06-22 01:59:07 -07:00
|
|
|
args = args[1:]
|
2017-06-20 19:27:38 -07:00
|
|
|
|
2017-06-22 01:59:07 -07:00
|
|
|
elif args[1] == '-uc':
|
2017-06-22 02:30:05 -07:00
|
|
|
g.casefold_upper = True
|
2017-06-22 01:59:07 -07:00
|
|
|
args = args[1:]
|
2017-06-20 19:27:38 -07:00
|
|
|
|
2017-06-22 01:59:07 -07:00
|
|
|
elif args[1] == '-ad':
|
2017-06-22 02:30:05 -07:00
|
|
|
g.use_appledouble = True
|
|
|
|
g.prodos_names = True
|
2017-06-22 01:59:07 -07:00
|
|
|
args = args[1:]
|
2017-06-20 19:27:38 -07:00
|
|
|
|
2017-06-22 01:59:07 -07:00
|
|
|
elif args[1] == '-shk':
|
2017-06-22 02:30:05 -07:00
|
|
|
g.src_shk = True
|
2017-06-22 01:59:07 -07:00
|
|
|
args = args[1:]
|
2017-06-20 19:27:38 -07:00
|
|
|
|
2017-06-22 01:59:07 -07:00
|
|
|
elif args[1] == '-pro':
|
2017-06-22 02:30:05 -07:00
|
|
|
g.prodos_names = True
|
2017-06-22 01:59:07 -07:00
|
|
|
args = args[1:]
|
2017-06-20 19:27:38 -07:00
|
|
|
|
2017-06-22 01:59:07 -07:00
|
|
|
elif args[1] == '-e':
|
2017-06-22 02:30:05 -07:00
|
|
|
g.use_extended = True
|
|
|
|
g.prodos_names = True
|
2017-06-22 01:59:07 -07:00
|
|
|
args = args[1:]
|
2017-06-20 19:27:38 -07:00
|
|
|
|
2017-06-22 01:59:07 -07:00
|
|
|
elif args[1] == '-cat':
|
2017-06-22 02:30:05 -07:00
|
|
|
g.catalog_only = True
|
2017-06-22 01:59:07 -07:00
|
|
|
args = args[1:]
|
2017-06-20 19:27:38 -07:00
|
|
|
|
2017-06-22 01:59:07 -07:00
|
|
|
else:
|
|
|
|
usage()
|
2017-06-20 19:27:38 -07:00
|
|
|
|
2017-06-22 02:30:05 -07:00
|
|
|
if g.use_appledouble and g.use_extended:
|
2017-06-20 19:27:38 -07:00
|
|
|
usage()
|
2017-06-22 02:30:05 -07:00
|
|
|
if g.catalog_only:
|
2017-06-22 01:59:07 -07:00
|
|
|
if len(args) != 2:
|
|
|
|
usage()
|
|
|
|
else:
|
|
|
|
if len(args) not in (3, 4):
|
|
|
|
usage()
|
2017-06-20 19:27:38 -07:00
|
|
|
|
2017-06-22 01:59:07 -07:00
|
|
|
g.image_file = args[1]
|
|
|
|
if not os.path.isfile(g.image_file):
|
|
|
|
print("Image/archive file \"" + g.image_file + "\" was not found.")
|
|
|
|
quitNow(2)
|
2017-06-20 19:27:38 -07:00
|
|
|
|
2017-06-22 01:59:07 -07:00
|
|
|
g.image_name = os.path.splitext(os.path.basename(g.image_file))
|
|
|
|
g.image_ext = g.image_name[1].lower()
|
2017-06-22 01:33:40 -07:00
|
|
|
|
2017-06-22 01:59:07 -07:00
|
|
|
# automatically set ShrinkIt mode if extension suggests it
|
2017-06-22 04:17:23 -07:00
|
|
|
if g.src_shk or g.image_ext in ('.shk', '.sdk', '.bxy'):
|
|
|
|
if os.name == "nt":
|
2017-06-22 01:59:07 -07:00
|
|
|
print("ShrinkIt archives cannot be extracted on Windows.")
|
2017-06-20 19:27:38 -07:00
|
|
|
quitNow(2)
|
2017-06-22 01:59:07 -07:00
|
|
|
else:
|
|
|
|
try:
|
|
|
|
with open(os.devnull, "w") as fnull:
|
|
|
|
subprocess.call("nulib2", stdout = fnull, stderr = fnull)
|
2017-06-22 02:30:05 -07:00
|
|
|
g.src_shk = True
|
2017-06-22 01:59:07 -07:00
|
|
|
except Exception:
|
|
|
|
print("Nulib2 is not available; not expanding ShrinkIt archive.")
|
|
|
|
quitNow(2)
|
2017-06-20 19:27:38 -07:00
|
|
|
|
2017-06-22 04:17:23 -07:00
|
|
|
if len(args) == 4:
|
2017-06-22 01:59:07 -07:00
|
|
|
g.extract_file = args[2]
|
|
|
|
|
|
|
|
if g.extract_file:
|
|
|
|
targetPath = args[3]
|
|
|
|
if os.path.isdir(targetPath):
|
2017-06-22 02:30:05 -07:00
|
|
|
g.target_dir = targetPath
|
2017-06-22 04:17:23 -07:00
|
|
|
elif targetPath.rsplit("/", 1) > 1:
|
2017-06-22 02:30:05 -07:00
|
|
|
g.target_dir = targetPath.rsplit("/", 1)[0]
|
|
|
|
g.target_name = targetPath.rsplit("/", 1)[1]
|
|
|
|
if not os.path.isdir(g.target_dir):
|
2017-06-20 19:27:38 -07:00
|
|
|
print("Target directory not found.")
|
|
|
|
quitNow(2)
|
2017-06-22 01:59:07 -07:00
|
|
|
else:
|
2017-06-22 02:30:05 -07:00
|
|
|
if not g.catalog_only:
|
2017-06-22 01:59:07 -07:00
|
|
|
if not os.path.isdir(args[2]):
|
|
|
|
print("Target directory not found.")
|
|
|
|
quitNow(2)
|
2017-06-20 19:27:38 -07:00
|
|
|
|
2017-06-22 02:30:05 -07:00
|
|
|
if g.src_shk:
|
|
|
|
g.prodos_names = False
|
|
|
|
if not g.catalog_only:
|
2017-06-22 01:59:07 -07:00
|
|
|
targetDir = (args[3] if g.extract_file else args[2])
|
|
|
|
unshkdir = ('/tmp' + "/cppo-" + str(uuid.uuid4()))
|
|
|
|
makedirs(unshkdir)
|
|
|
|
result = os.system("/bin/bash -c 'cd " + unshkdir + "; " +
|
|
|
|
"result=$(nulib2 -xse " + os.path.abspath(g.image_file) +
|
|
|
|
((" " + args[2].replace('/', ':'))
|
|
|
|
if g.extract_file else "") + " 2> /dev/null); " +
|
|
|
|
"if [[ $result == \"Failed.\" ]]; then exit 3; " +
|
|
|
|
"else if grep -q \"no records match\" <<< \"$result\"" +
|
|
|
|
" > /dev/null; then exit 2; else exit 0; fi; fi'")
|
2017-06-22 04:17:23 -07:00
|
|
|
if result == 512:
|
2017-06-22 01:59:07 -07:00
|
|
|
print("File not found in ShrinkIt archive. Try cppo -cat to get the path,")
|
|
|
|
print(" and omit any leading slash or colon.")
|
|
|
|
quitNow(1)
|
2017-06-22 04:17:23 -07:00
|
|
|
elif result != 0:
|
2017-06-22 01:59:07 -07:00
|
|
|
print("ShrinkIt archive is invalid, or some other problem happened.")
|
|
|
|
quitNow(1)
|
|
|
|
if g.extract_file:
|
|
|
|
g.extract_file = g.extract_file.replace(':', '/')
|
|
|
|
extractPath = (unshkdir + "/" + g.extract_file)
|
|
|
|
extractPathDir = os.path.dirname(extractPath)
|
|
|
|
# move the extracted file to the root
|
|
|
|
newunshkdir = ('/tmp' + "/cppo-" + str(uuid.uuid4()))
|
|
|
|
makedirs(newunshkdir)
|
|
|
|
for filename in os.listdir(extractPathDir):
|
|
|
|
shutil.move(extractPathDir + "/" + filename, newunshkdir)
|
|
|
|
shutil.rmtree(unshkdir)
|
|
|
|
unshkdir = newunshkdir
|
|
|
|
|
|
|
|
fileNames = [name for name in sorted(os.listdir(unshkdir))
|
|
|
|
if not name.startswith(".")]
|
2017-06-22 02:30:05 -07:00
|
|
|
if g.extract_in_place: # extract in place from "-n"
|
2017-06-22 01:59:07 -07:00
|
|
|
curDir = True
|
|
|
|
elif (len(fileNames) == 1 and
|
|
|
|
os.path.isdir(unshkdir + "/" + fileNames[0])):
|
|
|
|
curDir = True # only one folder at top level, so extract in place
|
|
|
|
volumeName = toProdosName(fileNames[0])
|
|
|
|
elif (len(fileNames) == 1 and # disk image, so extract in place
|
|
|
|
fileNames[0][-1:] == "i"):
|
|
|
|
curDir = True
|
|
|
|
volumeName = toProdosName(fileNames[0].split("#")[0])
|
|
|
|
else: # extract in folder based on disk image name
|
|
|
|
curDir = False
|
|
|
|
volumeName = toProdosName(os.path.basename(g.image_file))
|
2017-06-22 04:17:23 -07:00
|
|
|
if volumeName[-4:].lower() in ('.shk', '.sdk', '.bxy'):
|
|
|
|
volumeName = volumeName[:-4]
|
2017-06-22 02:30:05 -07:00
|
|
|
if not g.catalog_only and not curDir and not g.extract_file:
|
2017-06-22 01:59:07 -07:00
|
|
|
print("Extracting into " + volumeName)
|
|
|
|
# recursively process unshrunk archive hierarchy
|
|
|
|
for dirName, subdirList, fileList in os.walk(unshkdir):
|
|
|
|
subdirList.sort()
|
2017-06-22 02:30:05 -07:00
|
|
|
if not g.catalog_only:
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
g.target_dir = (targetDir + ("" if curDir else ("/" +
|
|
|
|
volumeName)) + ("/" if dirName.count('/') > 2 else "") +
|
|
|
|
("/".join(dirName.split('/')[3:]))) # chop tempdir
|
2017-06-22 01:59:07 -07:00
|
|
|
if g.extract_file: # solo item, so don't put it in the tree
|
2017-06-22 02:30:05 -07:00
|
|
|
g.target_dir = targetDir
|
|
|
|
if g.casefold_upper:
|
|
|
|
g.target_dir = g.target_dir.upper()
|
|
|
|
g.appledouble_dir = (g.target_dir + "/.AppleDouble")
|
|
|
|
makedirs(g.target_dir)
|
|
|
|
if g.use_appledouble:
|
|
|
|
makedirs(g.appledouble_dir)
|
2017-06-22 01:59:07 -07:00
|
|
|
for fname in sorted(fileList):
|
2017-06-22 04:17:23 -07:00
|
|
|
if fname[-1:] == "i":
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
# disk image; rename to include suffix and correct
|
|
|
|
# type/auxtype
|
2017-06-22 01:59:07 -07:00
|
|
|
imagePath = os.path.join(dirName, fname).split("#")[0]
|
|
|
|
new_name = (imagePath +
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
("" if os.path.splitext(imagePath.lower())[1]
|
|
|
|
in ('.po', '.hdv') else ".PO") +
|
|
|
|
"#e00005")
|
2017-06-22 01:59:07 -07:00
|
|
|
os.rename(os.path.join(dirName, fname), new_name)
|
|
|
|
fname = os.path.basename(new_name)
|
|
|
|
g.shk_hasrf = False
|
|
|
|
rfork = False
|
|
|
|
if (fname[-1:] == "r" and
|
|
|
|
os.path.isfile(os.path.join(dirName, fname[:-1]))):
|
|
|
|
rfork = True
|
|
|
|
elif (os.path.isfile(os.path.join(dirName, (fname + "r")))):
|
|
|
|
g.shk_hasrf = True
|
|
|
|
if not rfork:
|
|
|
|
processEntry(dirName, fname)
|
|
|
|
shutil.rmtree(unshkdir, True)
|
|
|
|
quitNow(0)
|
|
|
|
|
|
|
|
# end script if SHK
|
|
|
|
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
g.image_data = load_file(g.image_file)
|
2017-06-22 01:59:07 -07:00
|
|
|
|
2017-06-22 02:30:05 -07:00
|
|
|
# detect if image is 2mg and remove 64-byte header if so
|
2017-06-22 01:59:07 -07:00
|
|
|
if g.image_ext in ('.2mg', '.2img'):
|
|
|
|
g.image_data = g.image_data[64:]
|
|
|
|
|
|
|
|
# handle 140K disk image
|
2017-06-22 04:17:23 -07:00
|
|
|
if len(g.image_data) == 143360:
|
2017-06-22 01:59:07 -07:00
|
|
|
#print("140K disk")
|
2017-06-22 02:30:05 -07:00
|
|
|
prodos_disk = False
|
|
|
|
fix_order = False
|
2017-06-22 01:59:07 -07:00
|
|
|
# is it ProDOS?
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
if g.image_data[sli(ts(0,0), 4)] == b'\x01\x38\xb0\x03':
|
2017-06-22 01:59:07 -07:00
|
|
|
#print("detected ProDOS by boot block")
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
if g.image_data[sli(ts(0,1)+3, 6)] == b'PRODOS':
|
2017-06-22 02:30:05 -07:00
|
|
|
prodos_disk = True
|
2017-06-22 01:59:07 -07:00
|
|
|
#print("order OK (PO)")
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
elif g.image_data[sli(ts(0,14)+3, 6)] == b'PRODOS':
|
2017-06-22 01:59:07 -07:00
|
|
|
#print("order needs fixing (DO)")
|
2017-06-22 02:30:05 -07:00
|
|
|
prodos_disk = True
|
|
|
|
fix_order = True
|
2017-06-22 01:59:07 -07:00
|
|
|
# is it DOS 3.3?
|
|
|
|
else:
|
|
|
|
#print("it's not ProDOS")
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
if g.image_data[ts(17,0)+3] == 3:
|
|
|
|
(vtocT,vtocS) = g.image_data[sli(ts(17,0) + 1,2)]
|
2017-06-22 04:17:23 -07:00
|
|
|
if vtocT<35 and vtocS<16:
|
2017-06-22 01:59:07 -07:00
|
|
|
#print("it's DOS 3.3")
|
2017-06-22 02:30:05 -07:00
|
|
|
g.dos33 = True
|
2017-06-22 01:59:07 -07:00
|
|
|
# it's DOS 3.3; check sector order next
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
if g.image_data[ts(17,14)+2] != 13:
|
2017-06-22 01:59:07 -07:00
|
|
|
#print("order needs fixing (PO)")
|
2017-06-22 02:30:05 -07:00
|
|
|
fix_order = True
|
2017-06-22 01:59:07 -07:00
|
|
|
#else: print("order OK (DO)")
|
|
|
|
# fall back on disk extension if weird boot block (e.g. AppleCommander)
|
2017-06-22 02:30:05 -07:00
|
|
|
if not prodos_disk and not g.dos33:
|
2017-06-22 01:59:07 -07:00
|
|
|
#print("format and ordering unknown, checking extension")
|
|
|
|
if g.image_ext in ('.dsk', '.do'):
|
2017-06-22 02:30:05 -07:00
|
|
|
fix_order = True
|
2017-06-22 01:59:07 -07:00
|
|
|
#print("extension indicates DO, changing to PO")
|
2017-06-22 02:30:05 -07:00
|
|
|
if fix_order:
|
2017-06-22 01:59:07 -07:00
|
|
|
#print("fixing order")
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
g.image_data = dopo_swap(g.image_data)
|
2017-06-22 01:59:07 -07:00
|
|
|
#print("saving fixed order file as outfile.dsk")
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
#save_file("outfile.dsk", g.image_data)
|
2017-06-22 01:59:07 -07:00
|
|
|
#print("saved")
|
|
|
|
|
2017-06-22 02:30:05 -07:00
|
|
|
if not prodos_disk and not g.dos33:
|
2017-06-22 01:59:07 -07:00
|
|
|
print("Warning: Unable to determine disk format, assuming ProDOS.")
|
|
|
|
|
|
|
|
# enforce leading slash if ProDOS
|
2017-06-22 02:30:05 -07:00
|
|
|
if (not g.src_shk and not g.dos33 and g.extract_file and
|
2017-06-22 01:59:07 -07:00
|
|
|
(args[2][0] not in ('/', ':'))):
|
|
|
|
usage()
|
|
|
|
|
2017-06-22 02:30:05 -07:00
|
|
|
if g.dos33:
|
2017-06-22 04:17:23 -07:00
|
|
|
disk_name = (g.image_name[0] if g.image_ext in ('.dsk', '.do', '.po')
|
2017-06-22 01:59:07 -07:00
|
|
|
else "".join(g.image_name))
|
2017-06-22 02:30:05 -07:00
|
|
|
if g.prodos_names:
|
2017-06-22 04:17:23 -07:00
|
|
|
disk_name = toProdosName(disk_name)
|
2017-06-22 02:30:05 -07:00
|
|
|
if not g.catalog_only:
|
|
|
|
g.target_dir = (args[3] if g.extract_file
|
2017-06-22 04:17:23 -07:00
|
|
|
else (args[2] + "/" + disk_name))
|
2017-06-22 02:30:05 -07:00
|
|
|
g.appledouble_dir = (g.target_dir + "/.AppleDouble")
|
|
|
|
makedirs(g.target_dir)
|
|
|
|
if g.use_appledouble:
|
|
|
|
makedirs(g.appledouble_dir)
|
2017-06-22 01:59:07 -07:00
|
|
|
if not g.extract_file:
|
2017-06-22 04:17:23 -07:00
|
|
|
print("Extracting into " + disk_name)
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
processDir(list(g.image_data[sli(ts(17,0)+1,2)]))
|
2017-06-22 01:59:07 -07:00
|
|
|
if g.extract_file:
|
|
|
|
print("ProDOS file not found within image file.")
|
|
|
|
quitNow(0)
|
2017-06-20 19:27:38 -07:00
|
|
|
|
2017-06-22 01:59:07 -07:00
|
|
|
# below: ProDOS
|
2017-06-20 19:27:38 -07:00
|
|
|
|
2017-06-22 01:59:07 -07:00
|
|
|
g.activeDirBlock = 0
|
|
|
|
g.activeFileName = ""
|
|
|
|
g.activeFileSize = 0
|
|
|
|
g.activeFileBytesCopied = 0
|
|
|
|
g.resourceFork = 0
|
|
|
|
g.PDOSPATH_INDEX = 0
|
2017-06-22 02:30:05 -07:00
|
|
|
g.prodos_names = False
|
2017-06-22 01:59:07 -07:00
|
|
|
|
|
|
|
if g.extract_file:
|
|
|
|
g.PDOSPATH = g.extract_file.replace(':', '/').split('/')
|
|
|
|
g.extract_file = None
|
|
|
|
if not g.PDOSPATH[0]:
|
|
|
|
g.PDOSPATH_INDEX += 1
|
|
|
|
g.PDOSPATH_SEGMENT = g.PDOSPATH[g.PDOSPATH_INDEX]
|
2017-06-22 02:30:05 -07:00
|
|
|
g.appledouble_dir = (g.target_dir + "/.AppleDouble")
|
2017-06-22 04:17:23 -07:00
|
|
|
if g.use_appledouble and not os.path.isdir(g.appledouble_dir):
|
2017-06-22 02:30:05 -07:00
|
|
|
mkdir(g.appledouble_dir)
|
2017-06-22 01:59:07 -07:00
|
|
|
processDir(2)
|
|
|
|
print("ProDOS file not found within image file.")
|
|
|
|
quitNow(2)
|
|
|
|
else:
|
2017-06-22 02:30:05 -07:00
|
|
|
if not g.catalog_only:
|
Remove bashbyter, misc cleanups, a bugfix
The full summary:
**ADDED**
- New dopo_swap swaps 140k images between DOS order and ProDOS order. This
function replaces code in the main program body which does the same thing.
- Add optional zfill parameter to to_bin. Considered this for to_hex, but
nowhere would that be used currently and I'd rather get rid of these lower
level support functions that mainly are there for Bashbyter (but for now
have larger direct use now that Bashbyter is gone.)
**CHANGED**
- In getFileLength for DOS 3.3 T/other files, initialize prevTSpair to [0,0]
which, when combined with the removal of Bashbyter and vestiges of Python2
support, makes `The Correspondent 4.4.dsk` both -cat and extract. (Noted
previously, we currently do nothing about the control characters in the
filenames on this disk. They extract as non-printables and they don't show
up properly in -cat.)
- Replaced 4294967296 (2**32) with 1<<32 for use in turning negative integers
into unsigned 32 bit integers. It's possible to int.to_bytes() in a way
that does this the way we want, and we ought to do that. The syntax is
longer than it needs to be though.
- Strip high bit of DOS 3.3 filenames more efficiently
- Replaced type("".encode().decode()) with str. That wasn't necessary, and
you might think otherwise is an example of why dropping Python 2 is a very
good idea.
- Use int.from_bytes() calls to replace reading several bytes by hand,
multiplying them by bit offsets, and adding them together.
- Made unixDateToADDate return four bytes instead of a hex-ustr because it
only had one caller which just converted the value to that format anyway.
- Misc slight changes like unStudlyCapping identifiers, saving a return value
rather than calling the function that creates it multiple times, tuple
assignment, and coding style
**REMOVED**
- slyce functions: {,bin_,dec_,hex_}slyce
- aToB conversions: binTo{Dec,Hex}, charTo{Dec,Hex}, decTo{Char,Hex},
hexTo{Bin,Char,Dec} (just use to_thing or do it better than that.)
- Removed: readchar{s,Dec,Hex}, writechar{s,sHex,Dec,Hex}
2017-06-24 03:22:26 -07:00
|
|
|
#print(args[0], args[1], args[2])
|
2017-06-22 02:30:05 -07:00
|
|
|
g.target_dir = (args[2] + "/" + getVolumeName().decode("L1"))
|
|
|
|
g.appledouble_dir = (g.target_dir + "/.AppleDouble")
|
|
|
|
if not os.path.isdir(g.target_dir):
|
|
|
|
makedirs(g.target_dir)
|
2017-06-22 04:17:23 -07:00
|
|
|
if g.use_appledouble and not os.path.isdir(g.appledouble_dir):
|
2017-06-22 02:30:05 -07:00
|
|
|
makedirs(g.appledouble_dir)
|
2017-06-22 01:59:07 -07:00
|
|
|
processDir(2)
|
2017-06-22 02:30:05 -07:00
|
|
|
if not g.catalog_only:
|
2017-06-22 01:59:07 -07:00
|
|
|
quitNow(0)
|