setter for vol name

This commit is contained in:
Elliot Nunn 2018-10-07 23:52:57 +08:00
parent 854e8b987c
commit 12cca25a70
2 changed files with 14 additions and 1 deletions

View File

@ -53,6 +53,10 @@ class AbstractFolder(collections.MutableMapping):
def __len__(self):
return len(self._maindict)
def __repr__(self):
the_dict = {self._prefdict[k]: v for (k, v) in self._maindict.items()}
return repr(the_dict)
def iter_paths(self):
for name, child in self.items():
print(name, child)

11
main.py
View File

@ -103,7 +103,16 @@ class Volume(_directory.AbstractFolder):
self.bootblocks = bytes(1024) # optional; for booting HFS volumes
self.crdate = 0 # date and time of volume creation
self.lsmod = 0 # date and time of last modification
self.name = b'Untitled'
self._name = b'Untitled'
@property
def name(self):
return self._name
@name.setter
def name(self, value):
if len(value) > 27:
raise ValueError('Max volume name length = 27')
self._name = value
def read(self, from_volume):
self._dirtree = {}