mirror of
https://github.com/love2d/love.git
synced 2026-08-20 04:30:09 +02:00
Support for >2GB DroppedFile in desktops.
This commit is contained in:
@@ -106,14 +106,25 @@ bool DroppedFile::isOpen() const
|
|||||||
|
|
||||||
int64 DroppedFile::getSize()
|
int64 DroppedFile::getSize()
|
||||||
{
|
{
|
||||||
|
int fd = file ? fileno(file) : -1;
|
||||||
|
|
||||||
#ifdef LOVE_WINDOWS
|
#ifdef LOVE_WINDOWS
|
||||||
|
|
||||||
|
struct _stat64 buf;
|
||||||
|
|
||||||
// make sure non-ASCII filenames work.
|
if (fd != -1)
|
||||||
std::wstring wfilename = to_widestr(filename);
|
{
|
||||||
|
if (_fstat64(fd, &buf) != 0)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// make sure non-ASCII filenames work.
|
||||||
|
std::wstring wfilename = to_widestr(filename);
|
||||||
|
|
||||||
struct _stat buf;
|
if (_wstat64(wfilename.c_str(), &buf) != 0)
|
||||||
if (_wstat(wfilename.c_str(), &buf) != 0)
|
return -1;
|
||||||
return -1;
|
}
|
||||||
|
|
||||||
return (int64) buf.st_size;
|
return (int64) buf.st_size;
|
||||||
|
|
||||||
@@ -121,7 +132,13 @@ int64 DroppedFile::getSize()
|
|||||||
|
|
||||||
// Assume POSIX support...
|
// Assume POSIX support...
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
if (stat(filename.c_str(), &buf) != 0)
|
|
||||||
|
if (fd != -1)
|
||||||
|
{
|
||||||
|
if (fstat(fd, &buf) != 0)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else if (stat(filename.c_str(), &buf) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return (int64) buf.st_size;
|
return (int64) buf.st_size;
|
||||||
@@ -173,12 +190,22 @@ int64 DroppedFile::tell()
|
|||||||
if (file == nullptr)
|
if (file == nullptr)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return (int64) ftell(file);
|
#ifdef LOVE_WINDOWS
|
||||||
|
return (int64) _ftelli64(file);
|
||||||
|
#else
|
||||||
|
return (int64) ftello(file);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DroppedFile::seek(uint64 pos)
|
bool DroppedFile::seek(uint64 pos)
|
||||||
{
|
{
|
||||||
return file != nullptr && fseek(file, (long) pos, SEEK_SET) == 0;
|
return file != nullptr &&
|
||||||
|
|
||||||
|
#ifdef LOVE_WINDOWS
|
||||||
|
_fseeki64(file, (int64) pos, SEEK_SET) == 0;
|
||||||
|
#else
|
||||||
|
fseeko(file, (off_t) pos, SEEK_SET) == 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DroppedFile::setBuffer(BufferMode bufmode, int64 size)
|
bool DroppedFile::setBuffer(BufferMode bufmode, int64 size)
|
||||||
|
|||||||
Reference in New Issue
Block a user