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

Method read_file

recipes/Python/492211_dal3py/recipe-492211.py:246–267  ·  view source on GitHub ↗
(self, block)

Source from the content-addressed store, hash-verified

244
245 # Read A File
246 def read_file(self, block):
247 assert type(block) is int and 1 <= block <= self.__blocks
248 status = self.__disk.status(block)
249 assert self.STATUS.f1 <= status <= self.STATUS.fZ
250 if status == self.STATUS.f1:
251 temp = self.__disk.read(block)
252 size = (ord(temp[0]) << 8) + ord(temp[1])
253 return temp[2:size+2]
254 else:
255 while self.__disk.status(block) != self.STATUS.fA:
256 temp = self.__disk.read(block)
257 block = (ord(temp[0]) << 8) + ord(temp[1])
258 temp = self.__disk.read(block)
259 size = (ord(temp[0]) << 8) + ord(temp[1])
260 data = temp[2:-2]
261 block = (ord(temp[-2]) << 8) + ord(temp[-1])
262 while self.__disk.status(block) == self.STATUS.fB:
263 temp = self.__disk.read(block)
264 data += temp[2:-2]
265 block = (ord(temp[-2]) << 8) + ord(temp[-1])
266 temp = self.__disk.read(block)
267 return data + temp[2:size-len(data)+2]
268
269 # Write A File
270 def write_file(self, block, data):

Callers

nothing calls this directly

Calls 2

statusMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected