aboutsummaryrefslogtreecommitdiff
path: root/src/FileStream.cpp
diff options
context:
space:
mode:
authorLadislav Zezula <ladislav.zezula@avg.com>2013-12-06 15:20:47 +0100
committerLadislav Zezula <ladislav.zezula@avg.com>2013-12-06 15:20:47 +0100
commitf2a388780f83cfd95afa27b01dafe3a683b0e39c (patch)
tree34137a334e713c088a41ea2bdbdba0648df5f00b /src/FileStream.cpp
parentc34c37b3418f1e5ab3678ce65d46f81803dec91d (diff)
+ Bug fixes in SFileGetFileInfo, SAttrFileSaveToMpq, SListFileSaveToMpq
+ FileStream now handles files over 2GB properly + Test under Linux
Diffstat (limited to 'src/FileStream.cpp')
-rw-r--r--src/FileStream.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/FileStream.cpp b/src/FileStream.cpp
index 81933fd..03a8fea 100644
--- a/src/FileStream.cpp
+++ b/src/FileStream.cpp
@@ -182,7 +182,7 @@ static bool BaseFile_Read(
// we have to update the file position
if(ByteOffset != pStream->Base.File.FilePos)
{
- lseek((intptr_t)pStream->Base.File.hFile, (off_t)(ByteOffset), SEEK_SET);
+ lseek64((intptr_t)pStream->Base.File.hFile, (__off64_t)(ByteOffset), SEEK_SET);
pStream->Base.File.FilePos = ByteOffset;
}
@@ -271,7 +271,7 @@ static bool BaseFile_Write(TFileStream * pStream, ULONGLONG * pByteOffset, const
// we have to update the file position
if(ByteOffset != pStream->Base.File.FilePos)
{
- lseek((intptr_t)pStream->Base.File.hFile, (off_t)(ByteOffset), SEEK_SET);
+ lseek64((intptr_t)pStream->Base.File.hFile, (__off64_t)(ByteOffset), SEEK_SET);
pStream->Base.File.FilePos = ByteOffset;
}
@@ -346,7 +346,7 @@ static bool BaseFile_SetSize(TFileStream * pStream, ULONGLONG NewFileSize)
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
{
- if(ftruncate((intptr_t)pStream->Base.File.hFile, (off_t)NewFileSize) == -1)
+ if(ftruncate64((intptr_t)pStream->Base.File.hFile, (__off64_t)NewFileSize) == -1)
{
nLastError = errno;
return false;
@@ -429,7 +429,7 @@ static bool BaseFile_Create(
{
intptr_t handle;
- handle = open(szFileName, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+ handle = open(szFileName, O_RDWR | O_CREAT | O_TRUNC | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if(handle == -1)
{
nLastError = errno;
@@ -489,12 +489,12 @@ static bool BaseFile_Open(
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
{
- struct stat fileinfo;
+ struct stat64 fileinfo;
int oflag = (dwStreamFlags & STREAM_FLAG_READ_ONLY) ? O_RDONLY : O_RDWR;
intptr_t handle;
// Open the file
- handle = open(szFileName, oflag);
+ handle = open(szFileName, oflag | O_LARGEFILE);
if(handle == -1)
{
nLastError = errno;
@@ -502,7 +502,7 @@ static bool BaseFile_Open(
}
// Get the file size
- if(fstat(handle, &fileinfo) == -1)
+ if(fstat64(handle, &fileinfo) == -1)
{
nLastError = errno;
return false;
@@ -650,7 +650,7 @@ static bool BaseMap_Open(
#endif
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
- struct stat fileinfo;
+ struct stat64 fileinfo;
intptr_t handle;
bool bResult = false;
@@ -659,7 +659,7 @@ static bool BaseMap_Open(
if(handle != -1)
{
// Get the file size
- if(fstat(handle, &fileinfo) != -1)
+ if(fstat64(handle, &fileinfo) != -1)
{
pStream->Base.Map.pbFile = (LPBYTE)mmap(NULL, (size_t)fileinfo.st_size, PROT_READ, MAP_PRIVATE, handle, 0);
if(pStream->Base.Map.pbFile != NULL)