log4z
log4z copied to clipboard
Log4zFileHandler::open不支持单个2GB以上的文件
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;
}