0
파이썬 x86 원래 확장 라이브러리 내에서 큰 바이너리 데이터 (7GB
)를 관리하려고했습니다.
fseek
과 SEEK_END
이 잘 작동하지 않습니다.fseek with SEEK_END는 큰 데이터 (7GB)를 python x86 C extension lib에서 windows7 x64를 관리하기 위해 "잘못된 인수"오류를 반환합니다.
_FILE_OFFSET_BITS 64
매크로를 넣었습니다. 나는 또한 fseeko64
을 시도했지만 오류가 발생합니다.
2GB 미만의 파일 또는 SEEK_CUR, SEEK_SET을 사용하면 문제가 없습니다.
저는 며칠 동안 붙어 있습니다. 아무도 내게 아이디어를 줄 수 없습니까?
#define _GNU_SOURCE
#define _LARGEFILE_SOURCE
#define _LARGEFILE64_SOURCE
#define _FILE_OFFSET_BITS 64
#include <Python.h>
#include "structmember.h"
#include <stdio.h>
static PyObject *
MyClass_load(MyClass* self, PyObject *args)
{
const char* file_path;
if (!PyArg_ParseTuple(args, "s", &file_path))
return NULL;
self->fp = fopen(file_path ,"rb");
if (self->fp == NULL) {
PyErr_SetString(PyExc_IOError, "File does not exist.");
return NULL;
}
off_t offset = 0;
if(fseek(self->fp, offset, SEEK_END) != 0){
printf("%s\n", strerror(errno)); // show "Invalid argument"
PyErr_SetString(PyExc_IOError, "Seek failed.");
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
}
환경 :
- 윈도우 7 64
- 파이썬 '_fseeki64'와 VC와 같은 '_ftelli64'를 사용
- 는 MinGW GCC