mirror of
https://github.com/kiwix/kiwix-tools.git
synced 2025-09-24 04:20:56 -04:00
+ windows large file support fix
This commit is contained in:
parent
2c7c62dd3a
commit
db45abe6a3
@ -107,7 +107,12 @@ namespace zim
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef uint32_t size_type;
|
typedef uint32_t size_type;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
typedef __int64 offset_type;
|
||||||
|
#else
|
||||||
typedef uint64_t offset_type;
|
typedef uint64_t offset_type;
|
||||||
|
#endif
|
||||||
|
|
||||||
enum CompressionType
|
enum CompressionType
|
||||||
{
|
{
|
||||||
|
|||||||
@ -53,6 +53,9 @@ namespace zim
|
|||||||
#ifdef HAVE_STAT64
|
#ifdef HAVE_STAT64
|
||||||
struct stat64 st;
|
struct stat64 st;
|
||||||
int ret = ::stat64(fname, &st);
|
int ret = ::stat64(fname, &st);
|
||||||
|
#elif _WIN32
|
||||||
|
struct __stat64 st;
|
||||||
|
int ret = ::_stat64(fname, &st);
|
||||||
#else
|
#else
|
||||||
struct stat st;
|
struct stat st;
|
||||||
int ret = ::stat(fname, &st);
|
int ret = ::stat(fname, &st);
|
||||||
|
|||||||
@ -25,13 +25,13 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
//#include <unistd.h>
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
int _fmode = _O_BINARY;
|
int _fmode = _O_BINARY;
|
||||||
|
#define _LARGEFILE64_SOURCE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
log_define("zim.fstream")
|
log_define("zim.fstream")
|
||||||
@ -69,11 +69,11 @@ int streambuf::sync()
|
|||||||
|
|
||||||
streambuf::streambuf(const char* fname, unsigned bufsize)
|
streambuf::streambuf(const char* fname, unsigned bufsize)
|
||||||
: buffer(bufsize),
|
: buffer(bufsize),
|
||||||
#ifdef HAVE_OPEN64
|
#ifdef HAVE_OPEN64
|
||||||
fd(::open64(fname, 0))
|
fd(::open64(fname, 0))
|
||||||
#else
|
#else
|
||||||
fd(::open(fname, 0))
|
fd(::open(fname, 0))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
log_debug("streambuf for " << fname << " with " << bufsize << " bytes");
|
log_debug("streambuf for " << fname << " with " << bufsize << " bytes");
|
||||||
|
|
||||||
@ -93,11 +93,14 @@ streambuf::~streambuf()
|
|||||||
void streambuf::seekg(offset_type off)
|
void streambuf::seekg(offset_type off)
|
||||||
{
|
{
|
||||||
setg(0, 0, 0);
|
setg(0, 0, 0);
|
||||||
#ifdef HAVE_LSEEK64
|
#ifdef HAVE_LSEEK64
|
||||||
off64_t ret = ::lseek64(fd, off, SEEK_SET);
|
off64_t ret = ::lseek64(fd, off, SEEK_SET);
|
||||||
#else
|
#elif _WIN32
|
||||||
|
offset_type ret = ::_lseeki64(fd, off, SEEK_SET);
|
||||||
|
#else
|
||||||
off_t ret = ::lseek(fd, off, SEEK_SET);
|
off_t ret = ::lseek(fd, off, SEEK_SET);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
std::ostringstream msg;
|
std::ostringstream msg;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user