mirror of
https://github.com/gryf/uc1541.git
synced 2026-02-03 12:15:47 +01:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 426ac88926 | |||
| d75f87fdce | |||
| bda541dd92 | |||
| 6f359f7191 |
29
README.rst
29
README.rst
@@ -35,11 +35,10 @@ are seen on a listing.
|
|||||||
|
|
||||||
While copying from filesystem to disk image, filename conversion will be done:
|
While copying from filesystem to disk image, filename conversion will be done:
|
||||||
|
|
||||||
1. Every ``$`` and ``*`` characters will be replaced by question mark (``?``)
|
1. Every ``$`` and ``*`` characters will be replaced by question mark (``?``).
|
||||||
2. Every pipe (``|``) and backslash (``\``) characters will be replaced by
|
2. Every pipe (``|``) and backslash (``\\``) characters will be replaced by
|
||||||
slash (``/``)
|
slash (``/``).
|
||||||
3. Every tilde (``~``) will be replaced by a space
|
3. ``prg`` extension will be truncated.
|
||||||
4. ``prg`` extension will be truncated
|
|
||||||
|
|
||||||
Representation of a directory can be sometimes confusing - in case when one
|
Representation of a directory can be sometimes confusing - in case when one
|
||||||
copied file without extension it stays there in such form, till next access
|
copied file without extension it stays there in such form, till next access
|
||||||
@@ -57,20 +56,30 @@ file.
|
|||||||
Rquirements
|
Rquirements
|
||||||
===========
|
===========
|
||||||
|
|
||||||
* Python 2.7 or Python 3.6 or higher
|
* Python 3.6 or higher (checked recently with 3.11)
|
||||||
* Vice installation (c1541 program in path)
|
* Vice installation (c1541 program in path)
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
============
|
============
|
||||||
|
|
||||||
* copy ``uc1541`` to ``~/.local/share/mc/extfs.d/``
|
* copy ``uc1541`` to ``~/.local/share/mc/extfs.d/``
|
||||||
* add or change entry for files handle in ``~/.config/mc/mc.ext``::
|
* add or change entry for files handle in ``~/.config/mc/mc.ext``:
|
||||||
|
|
||||||
|
.. code:: ini
|
||||||
|
|
||||||
# Disk images for Commodore computers (VIC20, C64, C128)
|
# Disk images for Commodore computers (VIC20, C64, C128)
|
||||||
regex/\.([dD]64|[dD]6[zZ]|[dD]71|[dD]7[zZ]|[dD]81|[dD]8[zZ])$
|
[d64]
|
||||||
|
Regex=\.(d64|d71|d81)$
|
||||||
|
RegexIgnoreCase=true
|
||||||
Open=%cd %p/uc1541://
|
Open=%cd %p/uc1541://
|
||||||
View=%view{ascii} c1541 %f -list
|
View=%view{ascii} c1541 %f -list
|
||||||
Extract=c1541 %f -extract
|
|
||||||
|
[d6z]
|
||||||
|
Regex=\.(d[678]z)$
|
||||||
|
RegexIgnoreCase=true
|
||||||
|
Open=%cd %p/uc1541://
|
||||||
|
View=%view{ascii} t=$(mktemp); zcat %f > ${t}; c1541 ${t} -list 2>/dev/null; rm ${t}
|
||||||
|
|
||||||
|
|
||||||
Configuration
|
Configuration
|
||||||
=============
|
=============
|
||||||
@@ -87,6 +96,8 @@ script behaviour:
|
|||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
* **3.6** Fixed line matcher for directory entries.
|
||||||
|
* **3.5** Drop Python2 support.
|
||||||
* **3.4** Code cleanup. Removed dummy logger class and sys.args based argument
|
* **3.4** Code cleanup. Removed dummy logger class and sys.args based argument
|
||||||
parsing.
|
parsing.
|
||||||
* **3.3** Added support for .d71 and .d81 disk images.
|
* **3.3** Added support for .d71 and .d81 disk images.
|
||||||
|
|||||||
64
uc1541
64
uc1541
@@ -1,12 +1,12 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
"""
|
"""
|
||||||
UC1541 Virtual filesystem
|
UC1541 Virtual filesystem
|
||||||
|
|
||||||
Author: Roman 'gryf' Dobosz <gryf73@gmail.com>
|
Author: Roman 'gryf' Dobosz <gryf73@gmail.com>
|
||||||
Date: 2020-06-28
|
Date: 2023-10-04
|
||||||
Version: 3.4
|
Version: 3.6
|
||||||
Licence: BSD
|
Licence: BSD
|
||||||
source: https://bitbucket.org/gryf/uc1541
|
source: https://gihub.com/gryf/uc1541
|
||||||
mirror: https://github.com/gryf/uc1541
|
mirror: https://github.com/gryf/uc1541
|
||||||
"""
|
"""
|
||||||
import argparse
|
import argparse
|
||||||
@@ -32,18 +32,6 @@ if os.getenv('UC1541_DEBUG'):
|
|||||||
SECLEN = 256
|
SECLEN = 256
|
||||||
|
|
||||||
|
|
||||||
def _ord(string_or_int):
|
|
||||||
"""
|
|
||||||
Return an int value for the (possible) string passed in argument. This
|
|
||||||
function is for compatibility between python2 and python3, where single
|
|
||||||
element in byte string array is a string or an int respectively.
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
return ord(string_or_int)
|
|
||||||
except TypeError:
|
|
||||||
return string_or_int
|
|
||||||
|
|
||||||
|
|
||||||
def _get_raw(dimage):
|
def _get_raw(dimage):
|
||||||
"""
|
"""
|
||||||
Try to get contents of the D64 image either it's gzip compressed or not.
|
Try to get contents of the D64 image either it's gzip compressed or not.
|
||||||
@@ -137,10 +125,10 @@ class Disk(object):
|
|||||||
filename = list()
|
filename = list()
|
||||||
|
|
||||||
for chr_ in string:
|
for chr_ in string:
|
||||||
if _ord(chr_) == 160: # shift+space character; $a0
|
if chr_ == 160: # shift+space character; $a0
|
||||||
break
|
break
|
||||||
|
|
||||||
character = D64.CHAR_MAP.get(_ord(chr_), '?')
|
character = D64.CHAR_MAP.get(chr_, '?')
|
||||||
filename.append(character)
|
filename.append(character)
|
||||||
|
|
||||||
# special cases
|
# special cases
|
||||||
@@ -181,8 +169,8 @@ class Disk(object):
|
|||||||
if not self.current_sector_data:
|
if not self.current_sector_data:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self.next_track = _ord(self.current_sector_data[0])
|
self.next_track = self.current_sector_data[0]
|
||||||
self.next_sector = _ord(self.current_sector_data[1])
|
self.next_sector = self.current_sector_data[1]
|
||||||
|
|
||||||
if (self.next_track, self.next_sector) in self._already_done:
|
if (self.next_track, self.next_sector) in self._already_done:
|
||||||
# Just a failsafe. Endless loop is not what is expected.
|
# Just a failsafe. Endless loop is not what is expected.
|
||||||
@@ -216,7 +204,7 @@ class Disk(object):
|
|||||||
sector = self.current_sector_data
|
sector = self.current_sector_data
|
||||||
for dummy in range(8):
|
for dummy in range(8):
|
||||||
entry = sector[:32]
|
entry = sector[:32]
|
||||||
ftype = _ord(entry[2])
|
ftype = entry[2]
|
||||||
|
|
||||||
if ftype == 0: # deleted
|
if ftype == 0: # deleted
|
||||||
sector = sector[32:]
|
sector = sector[32:]
|
||||||
@@ -224,12 +212,12 @@ class Disk(object):
|
|||||||
|
|
||||||
type_verbose = self._get_ftype(ftype)
|
type_verbose = self._get_ftype(ftype)
|
||||||
|
|
||||||
protect = _ord(entry[2]) & 64 and "<" or " "
|
protect = entry[2] & 64 and "<" or " "
|
||||||
fname = entry[5:21]
|
fname = entry[5:21]
|
||||||
if ftype == 'rel':
|
if ftype == 'rel':
|
||||||
size = _ord(entry[23])
|
size = entry[23]
|
||||||
else:
|
else:
|
||||||
size = _ord(entry[30]) + _ord(entry[31]) * 226
|
size = entry[30] + entry[31] * 226
|
||||||
|
|
||||||
self._dir_contents.append({'fname': self._map_filename(fname),
|
self._dir_contents.append({'fname': self._map_filename(fname),
|
||||||
'ftype': type_verbose,
|
'ftype': type_verbose,
|
||||||
@@ -369,7 +357,7 @@ class Uc1541(object):
|
|||||||
"""
|
"""
|
||||||
Class for interact with c1541 program and MC
|
Class for interact with c1541 program and MC
|
||||||
"""
|
"""
|
||||||
PRG = re.compile(r'(\d+)\s+"([^"]*)".+?\s(del|prg|rel|seq|usr)([\s<])')
|
PRG = re.compile(r'(\d+)\s+"([^"]*)".+?(del|prg|rel|seq|usr)([\s<])')
|
||||||
|
|
||||||
def __init__(self, archname):
|
def __init__(self, archname):
|
||||||
self.arch = archname
|
self.arch = archname
|
||||||
@@ -447,9 +435,9 @@ class Uc1541(object):
|
|||||||
program seem to have issues with it while writing, so it will also be
|
program seem to have issues with it while writing, so it will also be
|
||||||
replaced.
|
replaced.
|
||||||
"""
|
"""
|
||||||
|
# TODO: revisit those shitty mappings, when are which done.
|
||||||
char_map = {'|': "/",
|
char_map = {'|': "/",
|
||||||
"\\": "/",
|
"\\": "/",
|
||||||
"~": " ",
|
|
||||||
"$": "?",
|
"$": "?",
|
||||||
"*": "?"}
|
"*": "?"}
|
||||||
|
|
||||||
@@ -507,13 +495,9 @@ class Uc1541(object):
|
|||||||
if '/' in display_name:
|
if '/' in display_name:
|
||||||
display_name = display_name.replace('/', '|')
|
display_name = display_name.replace('/', '|')
|
||||||
|
|
||||||
# workaround for space and dash at the beggining of the
|
# workaround for space at the beggining of the filename
|
||||||
# filename
|
if display_name.startswith(' '):
|
||||||
char_map = {' ': '~',
|
display_name = '_' + display_name[1:]
|
||||||
'-': '_'}
|
|
||||||
display_name = "".join([char_map.get(display_name[0],
|
|
||||||
display_name[0]),
|
|
||||||
display_name[1:]])
|
|
||||||
|
|
||||||
if ext == 'del':
|
if ext == 'del':
|
||||||
perms = "----------"
|
perms = "----------"
|
||||||
@@ -560,11 +544,15 @@ class Uc1541(object):
|
|||||||
universal_newlines = True
|
universal_newlines = True
|
||||||
if cmd in ['delete', 'write']:
|
if cmd in ['delete', 'write']:
|
||||||
universal_newlines = False
|
universal_newlines = False
|
||||||
(self.out,
|
#(self.out,
|
||||||
self.err) = subprocess.Popen(command,
|
# self.err) = subprocess.Popen(command,
|
||||||
universal_newlines=universal_newlines,
|
# universal_newlines=universal_newlines,
|
||||||
stdout=subprocess.PIPE,
|
# stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE).communicate()
|
# stderr=subprocess.PIPE).communicate()
|
||||||
|
out = subprocess.run(command, capture_output=True,
|
||||||
|
universal_newlines=universal_newlines)
|
||||||
|
|
||||||
|
self.out, self.err = out.stdout, out.stderr
|
||||||
|
|
||||||
if self.err:
|
if self.err:
|
||||||
LOG.debug('an err: %s', self.err)
|
LOG.debug('an err: %s', self.err)
|
||||||
|
|||||||
Reference in New Issue
Block a user