示例#1
0
    def unlink(self, path):
        if Format.check_file_data(Format, path):
            self.data.pop(path)
            Format.clear_data_block(Format, path)

        self.files.pop(path)
        Format.clear_metadata_block(Format, path)
示例#2
0
    def rmdir(self, path):
        # with multiple level support, need to raise ENOTEMPTY if contains any files
        length = len(path)

        flag = True
        for x in self.files:
            # if the first part is equal to path and the total length is longer than path
            # which mean it inside the path.
            if (x[0:length] == path) & (len(x) > length):
                flag = False

        if flag:
            self.files.pop(path)
            Format.clear_metadata_block(Format, path)
        else:
            raise ENOTEMPTY

        # find the parent path and reduce the nlink by 1.
        parent_path = Format.find_parent_path(Format, path)
        self.files[parent_path]['st_nlink'] -= 1
        Format.update_nlink(Format, parent_path, -1)