mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
Fix some warnings
This commit is contained in:
@@ -22,12 +22,13 @@
|
||||
|
||||
// STD
|
||||
#include <iostream>
|
||||
#include <climits>
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace filesystem
|
||||
{
|
||||
FileData::FileData(unsigned int size, const std::string & filename)
|
||||
FileData::FileData(uint64 size, const std::string & filename)
|
||||
: data(new char[size]), size(size), filename(filename)
|
||||
{
|
||||
if (filename.rfind('.') != std::string::npos)
|
||||
@@ -44,9 +45,15 @@ namespace filesystem
|
||||
return (void*)data;
|
||||
}
|
||||
|
||||
int FileData::getSize() const
|
||||
// TODO: Enable this
|
||||
/*uint64 FileData::getSize() const
|
||||
{
|
||||
return size;
|
||||
}*/
|
||||
|
||||
int FileData::getSize() const
|
||||
{
|
||||
return size > INT_MAX ? INT_MAX : (int) size;
|
||||
}
|
||||
|
||||
const std::string & FileData::getFilename() const
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <string>
|
||||
#include <common/Data.h>
|
||||
#include <common/StringMap.h>
|
||||
#include <common/int.h>
|
||||
|
||||
namespace love
|
||||
{
|
||||
@@ -38,7 +39,7 @@ namespace filesystem
|
||||
char * data;
|
||||
|
||||
// Size of the data.
|
||||
unsigned int size;
|
||||
uint64 size;
|
||||
|
||||
// The filename used for error purposes.
|
||||
std::string filename;
|
||||
@@ -55,12 +56,14 @@ namespace filesystem
|
||||
DECODE_MAX_ENUM
|
||||
}; // Decoder
|
||||
|
||||
FileData(unsigned int size, const std::string & filename);
|
||||
FileData(uint64 size, const std::string & filename);
|
||||
|
||||
virtual ~FileData();
|
||||
|
||||
// Implements Data.
|
||||
void * getData() const;
|
||||
//TODO: Enable this
|
||||
//uint64 getSize() const;
|
||||
int getSize() const;
|
||||
|
||||
const std::string & getFilename() const;
|
||||
@@ -79,4 +82,4 @@ namespace filesystem
|
||||
} // filesystem
|
||||
} // love
|
||||
|
||||
#endif // LOVE_FILESYSTEM_FILE_DATA_H
|
||||
#endif // LOVE_FILESYSTEM_FILE_DATA_H
|
||||
|
||||
@@ -139,6 +139,8 @@ namespace physfs
|
||||
int64 max = (int64)PHYSFS_fileLength(file);
|
||||
size = (size == ALL) ? max : size;
|
||||
size = (size > max) ? max : size;
|
||||
// Sadly, we'll have to clamp to 32 bits here
|
||||
size = (size > UINT32_MAX) ? UINT32_MAX : size;
|
||||
|
||||
int64 read = (int64)PHYSFS_read(file, dst, 1, size);
|
||||
|
||||
@@ -153,8 +155,11 @@ namespace physfs
|
||||
if (file == 0)
|
||||
throw love::Exception("Could not write to file. File not open.");
|
||||
|
||||
// Another clamp, for the time being.
|
||||
size = (size > UINT32_MAX) ? UINT32_MAX : size;
|
||||
|
||||
// Try to write.
|
||||
int written = static_cast<int64>(PHYSFS_write(file, data, 1, size));
|
||||
int64 written = static_cast<int64>(PHYSFS_write(file, data, 1, size));
|
||||
|
||||
// Check that correct amount of data was written.
|
||||
if (written != size)
|
||||
@@ -174,8 +179,8 @@ namespace physfs
|
||||
// It zigs, we zag.
|
||||
inline bool test_eof(File * that, PHYSFS_File *)
|
||||
{
|
||||
int pos = that->tell();
|
||||
int size = that->getSize();
|
||||
int64 pos = that->tell();
|
||||
int64 size = that->getSize();
|
||||
return pos == -1 || size == -1 || pos >= size;
|
||||
}
|
||||
#else
|
||||
|
||||
@@ -481,14 +481,14 @@ namespace physfs
|
||||
|
||||
// Find the next newline.
|
||||
// pos must be at the start of the line we're trying to find.
|
||||
int pos = file->tell();
|
||||
int64 pos = file->tell();
|
||||
int newline = -1;
|
||||
int totalread = 0;
|
||||
|
||||
while (!file->eof())
|
||||
{
|
||||
int current = file->tell();
|
||||
int read = file->read(buf, bufsize);
|
||||
int64 current = file->tell();
|
||||
int64 read = file->read(buf, bufsize);
|
||||
totalread += read;
|
||||
|
||||
if (read < 0)
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace physfs
|
||||
File * file = luax_checkfile(L, 1);
|
||||
Data * d = 0;
|
||||
|
||||
int64 size = (int64)luaL_optnumber(L, 2, file->getSize());
|
||||
int64 size = (int64)luaL_optnumber(L, 2, (lua_Number) file->getSize());
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user