Example #1
0
File: memory.py Project: egils/OS
 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)
Example #2
0
File: gui.py Project: egils/OS
 def getFileInfo(self, fileNr):
     content = []
     files = file_system.get_files()
     print ' '.join(files)
     if len(files)-1 < fileNr:
         stdout("Šis failas dar nesukurtas")
     else:
         file_name = files[fileNr]
         files[fileNr] = file_system.open(files[fileNr])
         try:
             file_content = '\n'.join(files[fileNr].data)
         except Exception, e:
             pass
         self.fileFrame = FileInfoFrame(self)
         app.SetTopWindow(self.fileFrame)
         self.fileFrame.file_name.SetLabel(str(file_name))
         self.fileFrame.file_contents.SetValue(str(file_content))
         self.fileFrame.Centre()
         self.fileFrame.Show()
Example #3
0
File: memory.py Project: egils/OS
    def file_open(self, name):
        u""" Atidaro failą skaitymui.

        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, tmp = self.get_file_descriptor(id)
            if mode == '0':
                self.set_file_descriptor(id, 'r', name)
                self.files[id] = self.create_reader(
                        file_system.open(name).read)
                return id
        raise Exception(u'Viršytas atidarytų failų limitas.')