Skip to content

Commit 5a60988

Browse files
committed
NSI: Auto-detect disk layout when importing *.nsi image file
1 parent cf6bd63 commit 5a60988

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

src/greaseweazle/image/nsi.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,25 @@
99
# This is free and unencumbered software released into the public domain.
1010
# See the file COPYING for more details, or visit <http://unlicense.org>.
1111

12-
from greaseweazle.image.img import IMG
12+
import os
1313

14-
class NSI(IMG):
15-
default_format = 'northstar.mfm.ds'
14+
from greaseweazle import error
15+
from greaseweazle.image.img import IMG_AutoFormat
16+
17+
class NSI(IMG_AutoFormat):
18+
19+
@staticmethod
20+
def format_from_file(name: str) -> str:
21+
size = os.path.getsize(name)
22+
if size == 1*35*10*256:
23+
return 'northstar.fm.ss'
24+
if size == 2*35*10*256:
25+
return 'northstar.fm.ds'
26+
if size == 1*35*10*512:
27+
return 'northstar.mfm.ss'
28+
if size == 2*35*10*512:
29+
return 'northstar.mfm.ds'
30+
raise error.Fatal(f'NSI: {name}: unrecognised file size')
1631

1732
def track_list(self):
1833
t, l = self.fmt.tracks, []

0 commit comments

Comments
 (0)