MCPcopy Create free account
hub / github.com/ActiveState/code / make_file

Method make_file

recipes/Python/492212_dal4py/recipe-492212.py:71–84  ·  view source on GitHub ↗
(self, block, name)

Source from the content-addressed store, hash-verified

69
70 # Make New File
71 def make_file(self, block, name):
72 assert type(block) is int and 1 <= block <= self.__blocks
73 assert type(name) is str and 1 <= len(name) <= 255
74 assert self.is_directory(block)
75 assert not self.exists(block, name)
76 root = self.__disk.read_directory(block)
77 new_file = self.__disk.open_file()
78 root += chr(new_file >> 8) + chr(new_file & 0xFF)
79 self.__disk.write_directory(block, root)
80 data = chr(block >> 8) + chr(block & 0xFF)
81 data += chr(len(name)) + name
82 data += '\x00' * 4
83 self.__disk.write_file(new_file, data)
84 return new_file
85
86 # Remove Old File
87 def remove_file(self, block):

Callers 2

__init__Method · 0.45
closeMethod · 0.45

Calls 6

is_directoryMethod · 0.95
existsMethod · 0.95
read_directoryMethod · 0.80
write_directoryMethod · 0.80
open_fileMethod · 0.45
write_fileMethod · 0.45

Tested by

no test coverage detected