Пример #1
0
 def _createRoot(self, name, content):
     self._root = Inode()
     self._rootName = name
     id = self._getFirstFreeInode()
     content = Inode.appendInode(content, self._root._id, name)
     pointers = self._fillBlocks(content)
     self._root.set(id, content, pointers, 1)
     self.write(self._root)
Пример #2
0
    def create(self, name, content):
        inode = Inode()
        id = self._getFirstFreeInode()

        #para diretórios, adiciona os inodes da pasta atual e raíz (cd .. e cd)
        if(content.split("|")[1] == ''):
            content = Inode.appendInode(content, self._root._id, self._rootName)
            content = Inode.appendInode(content, self._current._id, "..")
        else:
            content = Inode.appendInode(content, id, name)
            
        pointers = self._fillBlocks(content)
        inode.set(id, content, pointers, 1)
        self.write(inode)

        inodeContent = self.seek(self._current)
        inodeContent = Inode.appendInode(inodeContent, id, name)
        inodeContent = inodeContent.replace("\n", "")

        for inodeBlock in self._current._pointers:
            self._disk.write(inodeBlock, inodeContent)

        self.write(self._current)
        return inode