def read(self, address): u""" Nuskaito iš atminties virtualios mašinos puslapiavimo lentelę. """ self.PLR, self.PLBR = self.memory.get_address_tuple(address) for id in range(4): mode, name = self.get_file_descriptor(id) if mode == 'i': self.files[id] = self.create_reader(self.stdin_handler) elif mode == 'o': self.files[id] = self.create_writer(self.stdout_handler) elif mode == 'r': self.files[id] = self.create_reader( file_system.open(name).read) elif mode == 'w': self.files[id] = self.create_writer( file_system.create(name).write)
def file_create(self, name): u""" Atidaro failą rašymui. Sukuria failo deskriptorių ir grąžina failo id. """ for id in range(4): mode, file_name = self.get_file_descriptor(id) if mode != 0 and file_name == name: raise ValueError(u'Failas tokiu vardu jau atidarytas.') for id in range(4): mode, file_name = self.get_file_descriptor(id) if mode == '0': self.set_file_descriptor(id, 'w', name) self.files[id] = self.create_writer( file_system.create(name).write) return id raise Exception(u'Viršytas atidarytų failų limitas.')