Fix issue from #567 that stopped videos from working. Clean up some code.
This commit is contained in:
+22
-9
@@ -153,13 +153,7 @@ bool rFile::Open(const std::string &filename, rFile::OpenMode mode, int access)
|
||||
|
||||
bool rFile::Exists(const std::string &file)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
std::wstring wstr = ConvertUTF8ToWString(file);
|
||||
return GetFileAttributes(wstr.c_str()) != 0xFFFFFFFF;
|
||||
#else
|
||||
struct stat buffer;
|
||||
return (stat (file.c_str(), &buffer) == 0);
|
||||
#endif
|
||||
rExists(file);
|
||||
}
|
||||
|
||||
bool rFile::IsOpened() const
|
||||
@@ -215,6 +209,27 @@ bool rRmdir(const std::string &dir)
|
||||
#endif
|
||||
}
|
||||
|
||||
bool rRename(const std::string &from, const std::string &to)
|
||||
{
|
||||
// TODO: Deal with case-sensitivity
|
||||
#ifdef _WIN32
|
||||
return (MoveFile(ConvertUTF8ToWString(from).c_str(), ConvertUTF8ToWString(to).c_str()) == TRUE);
|
||||
#else
|
||||
return (0 == rename(from.c_str(), to.c_str()));
|
||||
#endif
|
||||
}
|
||||
|
||||
bool rExists(const std::string &file)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
std::wstring wstr = ConvertUTF8ToWString(file);
|
||||
return GetFileAttributes(wstr.c_str()) != 0xFFFFFFFF;
|
||||
#else
|
||||
struct stat buffer;
|
||||
return (stat (file.c_str(), &buffer) == 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool rDirExists(const std::string &path)
|
||||
{
|
||||
return wxDirExists(fmt::FromUTF8(path));
|
||||
@@ -287,8 +302,6 @@ bool rDir::GetNext(std::string *filename) const
|
||||
*filename = str.ToStdString();
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
rFileName::rFileName()
|
||||
{
|
||||
|
||||
@@ -45,6 +45,8 @@ std::string rGetCwd();
|
||||
bool rRmdir(const std::string& dir);
|
||||
bool rMkdir(const std::string& dir);
|
||||
bool rMkpath(const std::string& path);
|
||||
bool rRename(const std::string &from, const std::string &to);
|
||||
bool rExists(const std::string &path);
|
||||
bool rDirExists(const std::string &path);
|
||||
bool rFileExists(const std::string &path);
|
||||
bool rRemoveFile(const std::string &path);
|
||||
|
||||
Reference in New Issue
Block a user