Skip to content

Commit

Permalink
NSI: Auto-detect disk layout when importing *.nsi image file
Browse files Browse the repository at this point in the history
  • Loading branch information
keirf committed Jul 7, 2024
1 parent cf6bd63 commit 5a60988
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/greaseweazle/image/nsi.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,25 @@
# This is free and unencumbered software released into the public domain.
# See the file COPYING for more details, or visit <http://unlicense.org>.

from greaseweazle.image.img import IMG
import os

class NSI(IMG):
default_format = 'northstar.mfm.ds'
from greaseweazle import error
from greaseweazle.image.img import IMG_AutoFormat

class NSI(IMG_AutoFormat):

@staticmethod
def format_from_file(name: str) -> str:
size = os.path.getsize(name)
if size == 1*35*10*256:
return 'northstar.fm.ss'
if size == 2*35*10*256:
return 'northstar.fm.ds'
if size == 1*35*10*512:
return 'northstar.mfm.ss'
if size == 2*35*10*512:
return 'northstar.mfm.ds'
raise error.Fatal(f'NSI: {name}: unrecognised file size')

def track_list(self):
t, l = self.fmt.tracks, []
Expand Down

0 comments on commit 5a60988

Please sign in to comment.