本文整理汇总了Python中FileSystem.FileSystem.get_total_blocks方法的典型用法代码示例。如果您正苦于以下问题:Python FileSystem.get_total_blocks方法的具体用法?Python FileSystem.get_total_blocks怎么用?Python FileSystem.get_total_blocks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileSystem.FileSystem
的用法示例。
在下文中一共展示了FileSystem.get_total_blocks方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_filesystem
# 需要导入模块: from FileSystem import FileSystem [as 别名]
# 或者: from FileSystem.FileSystem import get_total_blocks [as 别名]
def add_filesystem(self, data, dos_type=DosType.DOS1, version=0):
# create a file system
blk_num = self._next_rdb_block()
fs_num = len(self.fs)
fs = FileSystem(self.rawblk, blk_num, fs_num)
# get total number of blocks for fs data
num_blks = fs.get_total_blocks(data)
# check if RDB has space left
if not self._has_free_rdb_blocks(num_blks):
return False
# allocate blocks
blks = self._alloc_rdb_blocks(num_blks)
self.used_blks += blks
self._update_hi_blk()
# create file system
fs.create(blks[1:], data, version, dos_type)
fs.write()
# link fs block
if len(self.fs) == 0:
# write into RDB
self.rdb.fs_list = blk_num
else:
# write into last fs block
last_fs = self.fs[-1]
last_fs.fshd.next = blk_num
last_fs.write(only_fshd=True)
# update rdb: allocated blocks and optional link
self.rdb.write()
# add fs to list
self.fs.append(fs)
return True