-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfdi.py
37 lines (29 loc) · 1.25 KB
/
fdi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from struct import *
import os
import unittest
def make_fdi_header(dummy=0,
fddtype=144,
headersize=4096,
fdd_size=1261568, # 2HD
sector_size=1024,
sector_count=8,
surfaces=2,
cylinders=77):
return pack("<8L4064x", dummy, fddtype, headersize, fdd_size, sector_size, sector_count, surfaces, cylinders)
def change_extension_of_path(old_path, new_extension):
destinationdir = os.path.dirname(old_path)
base_filename = os.path.basename(old_path)
new_filename = os.path.splitext(base_filename)[0] + new_extension
return os.path.join(destinationdir, new_filename)
def warn(warning_message):
print("WARNING: %s" % warning_message)
# TODO: unpack_fdi_header
class FdiTests(unittest.TestCase):
def test_fdi_header_is_correct_length(self):
header = make_fdi_header()
self.assertEqual(len(header), 4096, 'header should be 4096 bytes long')
def test_changing_extension_of_path(self):
renamed = change_extension_of_path('/Users/foobar/Documents/foobar.fdi', '.hdm')
self.assertEqual(renamed, '/Users/foobar/Documents/foobar.hdm')
if __name__ == '__main__':
unittest.main()