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

Method rename

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

Source from the content-addressed store, hash-verified

222
223 # Changes Directory/File Name
224 def rename(self, block, name):
225 assert type(block) is int and 2 <= block <= self.__blocks
226 assert type(name) is str and 1 <= len(name) <= 255
227 status = self.status(block)
228 assert status == self.STATUS.directory or status == self.STATUS.file
229 if status == self.STATUS.directory:
230 data = self.__disk.read_directory(block)
231 else:
232 data = self.__disk.read_file(block)
233 size = ord(data[2])
234 root = data[:2]
235 contents = data[size+3:]
236 new_name = chr(len(name)) + name
237 data = root + new_name + contents
238 if status == self.STATUS.directory:
239 self.__disk.write_directory(block, data)
240 else:
241 self.__disk.write_file(block, data)
242 return block
243
244 # Test For Existance
245 def exists(self, block, name):

Callers 12

renameFunction · 0.45
lower_namesFunction · 0.45
mainFunction · 0.45
recipe-435904.pyFile · 0.45
RenameWithTimeStampFunction · 0.45
tabifyFunction · 0.45
fix_ugly_namesFunction · 0.45
alreadydownloadedFunction · 0.45
recipe-224043.pyFile · 0.45
recipe-109357.pyFile · 0.45
callbackFunction · 0.45
threadRunMethod · 0.45

Calls 5

statusMethod · 0.95
read_directoryMethod · 0.80
write_directoryMethod · 0.80
read_fileMethod · 0.45
write_fileMethod · 0.45

Tested by

no test coverage detected