mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-25 00:11:06 +00:00
File_util: Fix signedness and precision warnings
This commit is contained in:
parent
ab6a962f59
commit
bae02f20b4
@ -306,7 +306,7 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename)
|
|||||||
while (!feof(input))
|
while (!feof(input))
|
||||||
{
|
{
|
||||||
// read input
|
// read input
|
||||||
int rnum = fread(buffer, sizeof(char), BSIZE, input);
|
size_t rnum = fread(buffer, sizeof(char), BSIZE, input);
|
||||||
if (rnum != BSIZE)
|
if (rnum != BSIZE)
|
||||||
{
|
{
|
||||||
if (ferror(input) != 0)
|
if (ferror(input) != 0)
|
||||||
@ -319,7 +319,7 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// write output
|
// write output
|
||||||
int wnum = fwrite(buffer, sizeof(char), rnum, output);
|
size_t wnum = fwrite(buffer, sizeof(char), rnum, output);
|
||||||
if (wnum != rnum)
|
if (wnum != rnum)
|
||||||
{
|
{
|
||||||
LOG_ERROR(Common_Filesystem,
|
LOG_ERROR(Common_Filesystem,
|
||||||
@ -365,7 +365,7 @@ u64 GetSize(const std::string &filename)
|
|||||||
{
|
{
|
||||||
LOG_TRACE(Common_Filesystem, "%s: %lld",
|
LOG_TRACE(Common_Filesystem, "%s: %lld",
|
||||||
filename.c_str(), (long long)buf.st_size);
|
filename.c_str(), (long long)buf.st_size);
|
||||||
return buf.st_size;
|
return static_cast<u64>(buf.st_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_ERROR(Common_Filesystem, "Stat failed %s: %s",
|
LOG_ERROR(Common_Filesystem, "Stat failed %s: %s",
|
||||||
@ -382,26 +382,26 @@ u64 GetSize(const int fd)
|
|||||||
fd, GetLastErrorMsg());
|
fd, GetLastErrorMsg());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return buf.st_size;
|
return static_cast<u64>(buf.st_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Overloaded GetSize, accepts FILE*
|
// Overloaded GetSize, accepts FILE*
|
||||||
u64 GetSize(FILE *f)
|
u64 GetSize(FILE *f)
|
||||||
{
|
{
|
||||||
// can't use off_t here because it can be 32-bit
|
// can't use off_t here because it can be 32-bit
|
||||||
u64 pos = ftello(f);
|
s64 pos = ftello(f);
|
||||||
if (fseeko(f, 0, SEEK_END) != 0) {
|
if (fseeko(f, 0, SEEK_END) != 0) {
|
||||||
LOG_ERROR(Common_Filesystem, "GetSize: seek failed %p: %s",
|
LOG_ERROR(Common_Filesystem, "GetSize: seek failed %p: %s",
|
||||||
f, GetLastErrorMsg());
|
f, GetLastErrorMsg());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
u64 size = ftello(f);
|
s64 size = ftello(f);
|
||||||
if ((size != pos) && (fseeko(f, pos, SEEK_SET) != 0)) {
|
if ((size != pos) && (fseeko(f, pos, SEEK_SET) != 0)) {
|
||||||
LOG_ERROR(Common_Filesystem, "GetSize: seek failed %p: %s",
|
LOG_ERROR(Common_Filesystem, "GetSize: seek failed %p: %s",
|
||||||
f, GetLastErrorMsg());
|
f, GetLastErrorMsg());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return size;
|
return static_cast<u64>(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// creates an empty file filename, returns true on success
|
// creates an empty file filename, returns true on success
|
||||||
@ -827,7 +827,7 @@ void SplitFilename83(const std::string& filename, std::array<char, 9>& short_nam
|
|||||||
point = filename.rfind('.', point);
|
point = filename.rfind('.', point);
|
||||||
|
|
||||||
// Get short name.
|
// Get short name.
|
||||||
int j = 0;
|
size_t j = 0;
|
||||||
for (char letter : filename.substr(0, point)) {
|
for (char letter : filename.substr(0, point)) {
|
||||||
if (forbidden_characters.find(letter, 0) != std::string::npos)
|
if (forbidden_characters.find(letter, 0) != std::string::npos)
|
||||||
continue;
|
continue;
|
||||||
@ -838,14 +838,14 @@ void SplitFilename83(const std::string& filename, std::array<char, 9>& short_nam
|
|||||||
short_name[7] = '1';
|
short_name[7] = '1';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
short_name[j++] = toupper(letter);
|
short_name[j++] = static_cast<char>(toupper(letter));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get extension.
|
// Get extension.
|
||||||
if (point != std::string::npos) {
|
if (point != std::string::npos) {
|
||||||
j = 0;
|
j = 0;
|
||||||
for (char letter : filename.substr(point + 1, 3))
|
for (char letter : filename.substr(point + 1, 3))
|
||||||
extension[j++] = toupper(letter);
|
extension[j++] = static_cast<char>(toupper(letter));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -938,7 +938,7 @@ bool IOFile::Seek(s64 off, int origin)
|
|||||||
return m_good;
|
return m_good;
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 IOFile::Tell()
|
s64 IOFile::Tell()
|
||||||
{
|
{
|
||||||
if (IsOpen())
|
if (IsOpen())
|
||||||
return ftello(m_file);
|
return ftello(m_file);
|
||||||
@ -963,7 +963,7 @@ bool IOFile::Resize(u64 size)
|
|||||||
_chsize_s(_fileno(m_file), size)
|
_chsize_s(_fileno(m_file), size)
|
||||||
#else
|
#else
|
||||||
// TODO: handle 64bit and growing
|
// TODO: handle 64bit and growing
|
||||||
ftruncate(fileno(m_file), size)
|
ftruncate(fileno(m_file), static_cast<s64>(size))
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
m_good = false;
|
m_good = false;
|
||||||
|
@ -248,7 +248,7 @@ public:
|
|||||||
void SetHandle(std::FILE* file);
|
void SetHandle(std::FILE* file);
|
||||||
|
|
||||||
bool Seek(s64 off, int origin);
|
bool Seek(s64 off, int origin);
|
||||||
u64 Tell();
|
s64 Tell();
|
||||||
u64 GetSize();
|
u64 GetSize();
|
||||||
bool Resize(u64 size);
|
bool Resize(u64 size);
|
||||||
bool Flush();
|
bool Flush();
|
||||||
|
Loading…
Reference in New Issue
Block a user