We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ftell 和fseek只支持返回 long ,就是32位,最大2GB文件,超过2GB的文件会返回-1。
inline long open(const char *path, const char * mod) { if (_file != NULL){fclose(_file);_file = NULL;} _file = fopen(path, mod); if (_file) { long tel = 0; long cur = ftell(_file); fseek(_file, 0L, SEEK_END); tel = ftell(_file); fseek(_file, cur, SEEK_SET); return tel; } return -1; }
可以改成: 同时要修改相关变量的数据类型 int型到int64_t
inline int64_t open64(const char *path, const char * mod) { if (_file != NULL) { fclose(_file); _file = NULL; } _file = fopen(path, mod); if (_file) { #ifdef WIN32 #define ftell64 _ftelli64 #define fseek64 _fseeki64 #else #define ftell64 ftello64 #define fseek64 fseeko64 #endif //along 支持2G以上的文件 int64_t tel = 0; auto cur = ftell64(_file); fseek64(_file, 0L, SEEK_END); tel = ftell64(_file); fseek64(_file, cur, SEEK_SET); return tel; } return -1; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
ftell 和fseek只支持返回 long ,就是32位,最大2GB文件,超过2GB的文件会返回-1。
可以改成:
同时要修改相关变量的数据类型 int型到int64_t
The text was updated successfully, but these errors were encountered: