uos -- 基本的 "操作系统" 服务¶
os 模块包含用于文件系统访问和``urandom``功能。
函数¶
-
uos.chdir(path)¶ 更改当前目录。
-
uos.getcwd()¶ 获取当前目录。
-
uos.ilistdir([dir])¶ 这个函数返回一个迭代器,然后产生三元组对应正在列出的目录中的条目。没有参数,它列出了
当前目录,否则它列出了目录给出的`dir`。
3-元组的形式`(name, type, inode)`:
- name 是一个字符串(或字节,如果是一个字节对象),是输入的名称;
- type 是一个整数,指定的条目类型,与普通文件和目录0x4000 0x8000;
- inode 对应文件的inode的整数,可0的文件系统,没有这样的概念。
-
uos.listdir([dir])¶ 没有参数,列出当前目录。否则列出给定目录。
-
uos.mkdir(path)¶ 创建一个目录。
-
uos.remove(path)¶ 删除文件。
-
uos.rmdir(path)¶ 删除目录。
-
uos.rename(old_path, new_path)¶ 重命名文件。
-
uos.stat(path)¶ 获取文件或目录的状态。
-
uos.statvfs(path)¶ 得到一个文件系统的状态。
按下列顺序返回带有文件系统信息的元组:
f_bsize-- file system block sizef_frsize-- fragment sizef_blocks-- size of fs in f_frsize unitsf_bfree-- number of free blocksf_bavail-- number of free blocks for unpriviliged usersf_files-- number of inodesf_ffree-- number of free inodesf_favail-- number of free inodes for unpriviliged usersf_flag-- mount flagsf_namemax-- maximum filename length
Parameters related to inodes:
f_files,f_ffree,f_availand thef_flagsparameter may return0as they can be unavailable in a port-specific implementation.
-
uos.sync()¶ 同步所有的文件系统。
-
uos.urandom(n)¶ 返回带有n个随机字节的字节对象。它由硬件随机数生成器生成。