mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
support f.read()
This commit is contained in:
parent
3d3cfd4e25
commit
bd9bd8b864
@ -155,7 +155,7 @@ class ByteArray:
|
||||
|
||||
class FILEIO:
|
||||
def init(self, path: str, mode: str) -> int: ...
|
||||
def read(self, size: int) -> any: ...
|
||||
def read(self, *size) -> any: ...
|
||||
def write(self, s: any) -> int: ...
|
||||
def close(self): ...
|
||||
def seek(self, offset: int, *fromwhere) -> int: ...
|
||||
|
@ -25,7 +25,13 @@ void PikaStdData_FILEIO_close(PikaObj* self) {
|
||||
obj_setPtr(self, "_f", NULL);
|
||||
}
|
||||
|
||||
Arg* PikaStdData_FILEIO_read(PikaObj* self, int size) {
|
||||
Arg* PikaStdData_FILEIO_read(PikaObj* self, PikaTuple* size_) {
|
||||
int size = 0;
|
||||
if (pikaTuple_getSize(size_) == 0) {
|
||||
size = -1;
|
||||
}else{
|
||||
size = pikaTuple_getInt(size_, 0);
|
||||
}
|
||||
if (size <= 0) {
|
||||
/* read all */
|
||||
size = PIKA_READ_FILE_BUFF_SIZE;
|
||||
|
@ -155,7 +155,7 @@ class ByteArray:
|
||||
|
||||
class FILEIO:
|
||||
def init(self, path: str, mode: str) -> int: ...
|
||||
def read(self, size: int) -> any: ...
|
||||
def read(self, *size) -> any: ...
|
||||
def write(self, s: any) -> int: ...
|
||||
def close(self): ...
|
||||
def seek(self, offset: int, *fromwhere) -> int: ...
|
||||
|
@ -25,7 +25,13 @@ void PikaStdData_FILEIO_close(PikaObj* self) {
|
||||
obj_setPtr(self, "_f", NULL);
|
||||
}
|
||||
|
||||
Arg* PikaStdData_FILEIO_read(PikaObj* self, int size) {
|
||||
Arg* PikaStdData_FILEIO_read(PikaObj* self, PikaTuple* size_) {
|
||||
int size = 0;
|
||||
if (pikaTuple_getSize(size_) == 0) {
|
||||
size = -1;
|
||||
}else{
|
||||
size = pikaTuple_getInt(size_, 0);
|
||||
}
|
||||
if (size <= 0) {
|
||||
/* read all */
|
||||
size = PIKA_READ_FILE_BUFF_SIZE;
|
||||
|
Loading…
x
Reference in New Issue
Block a user