Merge branch 'dev' into dev-graphics-overhaul
commit
9d5f88f07c
|
@ -77,7 +77,7 @@ std::streambuf::int_type CInputStreamBuffer::underflow()
|
|||
if (PHYSFS_eof(m_file))
|
||||
return traits_type::eof();
|
||||
|
||||
PHYSFS_sint64 read_count = PHYSFS_read(m_file, m_buffer.get(), sizeof(char), m_bufferSize);
|
||||
PHYSFS_sint64 read_count = PHYSFS_readBytes(m_file, m_buffer.get(), sizeof(char) * m_bufferSize);
|
||||
if (read_count <= 0)
|
||||
return traits_type::eof();
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ std::streambuf::int_type COutputStreamBuffer::overflow(std::streambuf::int_type
|
|||
return 0;
|
||||
|
||||
// save buffer
|
||||
PHYSFS_sint64 bytes_written = PHYSFS_write(m_file, pbase(), 1, pptr() - pbase());
|
||||
PHYSFS_sint64 bytes_written = PHYSFS_writeBytes(m_file, pbase(), pptr() - pbase());
|
||||
if (bytes_written <= 0)
|
||||
return traits_type::eof();
|
||||
|
||||
|
@ -86,7 +86,7 @@ std::streambuf::int_type COutputStreamBuffer::overflow(std::streambuf::int_type
|
|||
// write final char
|
||||
if (ch != traits_type::eof())
|
||||
{
|
||||
bytes_written = PHYSFS_write(m_file, &ch, 1, 1);
|
||||
bytes_written = PHYSFS_writeBytes(m_file, &ch, 1);
|
||||
if (bytes_written <= 0)
|
||||
return traits_type::eof();
|
||||
}
|
||||
|
|
|
@ -37,7 +37,8 @@ CResourceManager::CResourceManager(const char *argv0)
|
|||
{
|
||||
if (!PHYSFS_init(argv0))
|
||||
{
|
||||
GetLogger()->Error("Error while initializing physfs: %s\n", PHYSFS_getLastError());
|
||||
PHYSFS_ErrorCode errorCode = PHYSFS_getLastErrorCode();
|
||||
GetLogger()->Error("Error while initializing physfs: %s\n", PHYSFS_getErrorByCode(errorCode));
|
||||
assert(false);
|
||||
}
|
||||
PHYSFS_permitSymbolicLinks(1);
|
||||
|
@ -50,7 +51,8 @@ CResourceManager::~CResourceManager()
|
|||
{
|
||||
if (!PHYSFS_deinit())
|
||||
{
|
||||
GetLogger()->Error("Error while deinitializing physfs: %s\n", PHYSFS_getLastError());
|
||||
PHYSFS_ErrorCode errorCode = PHYSFS_getLastErrorCode();
|
||||
GetLogger()->Error("Error while deinitializing physfs: %s\n", PHYSFS_getErrorByCode(errorCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +67,8 @@ bool CResourceManager::AddLocation(const std::string &location, bool prepend, co
|
|||
{
|
||||
if (!PHYSFS_mount(location.c_str(), mountPoint.c_str(), prepend ? 0 : 1))
|
||||
{
|
||||
GetLogger()->Error("Error while mounting \"%s\": %s\n", location.c_str(), PHYSFS_getLastError());
|
||||
PHYSFS_ErrorCode errorCode = PHYSFS_getLastErrorCode();
|
||||
GetLogger()->Error("Error while mounting \"%s\": %s\n", location.c_str(), PHYSFS_getErrorByCode(errorCode));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -75,9 +78,10 @@ bool CResourceManager::AddLocation(const std::string &location, bool prepend, co
|
|||
|
||||
bool CResourceManager::RemoveLocation(const std::string &location)
|
||||
{
|
||||
if (!PHYSFS_removeFromSearchPath(location.c_str()))
|
||||
if (!PHYSFS_unmount(location.c_str()))
|
||||
{
|
||||
GetLogger()->Error("Error while unmounting \"%s\": %s\n", location.c_str(), PHYSFS_getLastError());
|
||||
PHYSFS_ErrorCode errorCode = PHYSFS_getLastErrorCode();
|
||||
GetLogger()->Error("Error while unmounting \"%s\": %s\n", location.c_str(), PHYSFS_getErrorByCode(errorCode));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -105,7 +109,8 @@ bool CResourceManager::SetSaveLocation(const std::string &location)
|
|||
{
|
||||
if (!PHYSFS_setWriteDir(location.c_str()))
|
||||
{
|
||||
GetLogger()->Error("Error while setting save location to \"%s\": %s\n", location.c_str(), PHYSFS_getLastError());
|
||||
PHYSFS_ErrorCode errorCode = PHYSFS_getLastErrorCode();
|
||||
GetLogger()->Error("Error while setting save location to \"%s\": %s\n", location.c_str(), PHYSFS_getErrorByCode(errorCode));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -150,7 +155,9 @@ bool CResourceManager::DirectoryExists(const std::string& directory)
|
|||
{
|
||||
if (PHYSFS_isInit())
|
||||
{
|
||||
return PHYSFS_exists(CleanPath(directory).c_str()) && PHYSFS_isDirectory(CleanPath(directory).c_str());
|
||||
PHYSFS_Stat statbuf;
|
||||
PHYSFS_stat(CleanPath(directory).c_str(), &statbuf);
|
||||
return (PHYSFS_exists(CleanPath(directory).c_str()) && (statbuf.filetype == PHYSFS_FILETYPE_DIRECTORY));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -191,8 +198,10 @@ std::vector<std::string> CResourceManager::ListFiles(const std::string &director
|
|||
{
|
||||
if (excludeDirs)
|
||||
{
|
||||
PHYSFS_Stat statbuf;
|
||||
std::string path = CleanPath(directory) + "/" + (*i);
|
||||
if (PHYSFS_isDirectory(path.c_str())) continue;
|
||||
PHYSFS_stat(path.c_str(), &statbuf);
|
||||
if (statbuf.filetype == PHYSFS_FILETYPE_DIRECTORY) continue;
|
||||
}
|
||||
result.push_back(*i);
|
||||
}
|
||||
|
@ -213,8 +222,10 @@ std::vector<std::string> CResourceManager::ListDirectories(const std::string &di
|
|||
|
||||
for (char **i = files; *i != nullptr; i++)
|
||||
{
|
||||
PHYSFS_Stat statbuf;
|
||||
std::string path = CleanPath(directory) + "/" + (*i);
|
||||
if (PHYSFS_isDirectory(path.c_str()))
|
||||
PHYSFS_stat(path.c_str(), &statbuf);
|
||||
if (statbuf.filetype == PHYSFS_FILETYPE_DIRECTORY)
|
||||
{
|
||||
result.push_back(*i);
|
||||
}
|
||||
|
@ -243,7 +254,9 @@ long long CResourceManager::GetLastModificationTime(const std::string& filename)
|
|||
{
|
||||
if (PHYSFS_isInit())
|
||||
{
|
||||
return PHYSFS_getLastModTime(CleanPath(filename).c_str());
|
||||
PHYSFS_Stat statbuf;
|
||||
PHYSFS_stat(CleanPath(filename).c_str(), &statbuf);
|
||||
return statbuf.modtime;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ size_t CSDLFileWrapper::SDLRead(SDL_RWops *context, void *ptr, size_t size, size
|
|||
PHYSFS_File *file = static_cast<PHYSFS_File *>(context->hidden.unknown.data1);
|
||||
SDL_memset(ptr, 0, size * maxnum);
|
||||
|
||||
auto result = PHYSFS_read(file, ptr, size, maxnum);
|
||||
auto result = PHYSFS_readBytes(file, ptr, size * maxnum);
|
||||
return (result >= 0) ? result : 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ CSDLMemoryWrapper::CSDLMemoryWrapper(const std::string& filename)
|
|||
|
||||
PHYSFS_sint64 length = PHYSFS_fileLength(file);
|
||||
m_buffer = std::make_unique<char[]>(length);
|
||||
if (PHYSFS_read(file, m_buffer.get(), 1, length) != length)
|
||||
if (PHYSFS_readBytes(file, m_buffer.get(), length) != length)
|
||||
{
|
||||
GetLogger()->Error("Unable to read data for \"%s\"\n", filename.c_str());
|
||||
PHYSFS_close(file);
|
||||
|
|
|
@ -47,7 +47,8 @@ CSNDFileWrapper::CSNDFileWrapper(const std::string& filename)
|
|||
}
|
||||
else
|
||||
{
|
||||
m_last_error = std::string(PHYSFS_getLastError());
|
||||
PHYSFS_ErrorCode errorCode = PHYSFS_getLastErrorCode();
|
||||
m_last_error = std::string(PHYSFS_getErrorByCode(errorCode));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,7 +98,7 @@ sf_count_t CSNDFileWrapper::SNDLength(void *data)
|
|||
|
||||
sf_count_t CSNDFileWrapper::SNDRead(void *ptr, sf_count_t count, void *data)
|
||||
{
|
||||
return PHYSFS_read(static_cast<PHYSFS_File *>(data), ptr, 1, count);
|
||||
return PHYSFS_readBytes(static_cast<PHYSFS_File *>(data), ptr, count);
|
||||
}
|
||||
|
||||
|
||||
|
@ -129,5 +130,5 @@ sf_count_t CSNDFileWrapper::SNDTell(void *data)
|
|||
|
||||
sf_count_t CSNDFileWrapper::SNDWrite(const void *ptr, sf_count_t count, void *data)
|
||||
{
|
||||
return PHYSFS_write(static_cast<PHYSFS_File *>(data), ptr, 1, count);
|
||||
return PHYSFS_writeBytes(static_cast<PHYSFS_File *>(data), ptr, count);
|
||||
}
|
||||
|
|
|
@ -393,7 +393,7 @@ GLint LoadShader(GLint type, const char* filename)
|
|||
std::vector<GLchar> source(len + 1);
|
||||
|
||||
GLchar *sources[] = { source.data() };
|
||||
size_t length = PHYSFS_read(file, source.data(), 1, len);
|
||||
size_t length = PHYSFS_readBytes(file, source.data(), len);
|
||||
source[length] = '\0';
|
||||
|
||||
PHYSFS_close(file);
|
||||
|
|
Loading…
Reference in New Issue