1# -*- coding: UTF-8 -*-
2"""
3
4模块功能:提供操作系统相关的功能函数
5
6"""
7
8
9def set_header(header):
10    """
11    设置请求header参数
12
13    :param header(str): 设置请求的header参数
14    :returns: 0: 成功,其他: 失败
15
16    """
17    pass
18
19def open(path, mode):
20    """
21    打开文件,具体使用方式参考Linux C下的fopen函数。
22
23    :param path(str): 待打开的文件路径及文件名;
24    :param mode(str): 待打开的文件长度操作形态;
25    :returns(nil): 若文件打开成功,返回值为文件流指针。若文件打开失败, 则返回Null。
26    :raises OSError: ENOENT
27    """
28    pass
29
30def read(buf, size, nmemb, stream):
31    """
32    从文件流读取数据,具体使用方式参考Linux C下的fread函数。
33
34    :param buf(bytearray): 数据空间,用来存放读取进来的数据;
35    :param size(int): 待读取的每个数据项占据的字节数;
36    :param nmemb(int): 待读取的数据项数目,读取的总字符数以参数size*nmemb来决定;
37    :param stream(nil): 通过open函数获取到的已打开的文件指针;
38    :returns: 实际读取到的总字符数目。
39    :raises OSError: EINVAL
40    """
41    pass
42
43def write(buf, size, nmemb, stream):
44    """
45    从文件流写入数据,具体使用方式参考Linux C下的fwrite函数。
46
47    :param buf(bytearray): 数据空间,用来存放待写入的数据;
48    :param size(int): 待写入的每个数据项占据的字节数;
49    :param nmemb(int): 待写入的数据项数目,写入的总字符数以参数size*nmemb来决定;
50    :param stream(nil): 通过open函数获取到的已打开的文件指针;
51    :returns: 实际写入到的总字符数目。
52    :raises OSError: EINVAL
53    """
54    pass
55
56def close(stream):
57    """
58    关闭文件,具体使用方式参考Linux C下的fclose函数。
59
60    :param stream(nil): 通过open函数获取到的已打开的文件指针;
61    :returns: 0: 成功,其他: 失败
62    :raises OSError: EINVAL
63    """
64    pass
65
66def seek(buf, size, nmemb, stream):
67    """
68    移动文件流的读写位置,具体使用方式参考Linux C下的fseek函数。
69
70    :param stream(nil): 通过open函数获取到的已打开的文件指针;
71    :param offset(int): 相对 whence 的偏移量,以字节为单位;
72    :param whence(int): 开始添加偏移 offset 的位置,它一般指定为: SEEK_SET, SEEK_CUR和SEEK_END;
73
74    :returns: 0: 成功,其他: 失败
75    :raises OSError: EINVAL
76    """
77    pass
78
79def tell(stream):
80    """
81    获取给定流stream的当前文件位置,具体使用方式参考Linux C下的ftell函数。
82
83    :param stream(nil): 通过open函数获取到的已打开的文件指针;
84
85    :returns: 若获取成功则返回位置标识符的当前值;若获取失败则返回-1L。
86    :raises OSError: EINVAL
87    """
88    pass
89
90def rewind(stream):
91    """
92    设置文件位置为给定流stream的文件的开头,具体使用方式参考Linux C下的rewind函数。
93
94    :param stream(nil): 通过open函数获取到的已打开的文件指针;
95
96    :returns: 空
97    :raises OSError: EINVAL
98    """
99    pass
100
101def getpos(stream):
102    """
103    获取流 stream 的当前文件位置,具体使用方式参考Linux C下的fgetpos函数。
104
105    :param stream(nil): 通过open函数获取到的已打开的文件指针;
106
107    :returns: 如果成功则返回当前文件位置,如果失败则返回-1。
108    :raises OSError: EINVAL
109    """
110    pass
111
112def setpos(stream, pos):
113    """
114    设置给定流 stream 的文件位置为给定的位置,具体使用方式参考Linux C下的fsetpos函数。
115
116    :param stream(nil): 通过open函数获取到的已打开的文件指针;
117    :param pos(int): 需要设置的文件位置;
118    :returns: 0: 成功,其他: 失败
119    :raises OSError: EINVAL
120    """
121    pass