summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/chunk_file.h8
-rw-r--r--src/common/file_util.cpp38
-rw-r--r--src/common/file_util.h2
-rw-r--r--src/common/log_manager.cpp2
-rw-r--r--src/core/loader/elf.cpp2
-rw-r--r--src/core/loader/loader.cpp2
-rw-r--r--src/core/loader/ncch.cpp6
-rw-r--r--src/video_core/debug_utils/debug_utils.cpp2
8 files changed, 31 insertions, 31 deletions
diff --git a/src/common/chunk_file.h b/src/common/chunk_file.h
index 2b0f120e6..7a3b537c7 100644
--- a/src/common/chunk_file.h
+++ b/src/common/chunk_file.h
@@ -671,7 +671,7 @@ public:
671 _failureReason->clear(); 671 _failureReason->clear();
672 _failureReason->append("LoadStateWrongVersion"); 672 _failureReason->append("LoadStateWrongVersion");
673 673
674 if (!File::Exists(_rFilename)) { 674 if (!FileUtil::Exists(_rFilename)) {
675 _failureReason->clear(); 675 _failureReason->clear();
676 _failureReason->append("LoadStateDoesntExist"); 676 _failureReason->append("LoadStateDoesntExist");
677 ERROR_LOG(COMMON, "ChunkReader: File doesn't exist"); 677 ERROR_LOG(COMMON, "ChunkReader: File doesn't exist");
@@ -679,7 +679,7 @@ public:
679 } 679 }
680 680
681 // Check file size 681 // Check file size
682 const u64 fileSize = File::GetSize(_rFilename); 682 const u64 fileSize = FileUtil::GetSize(_rFilename);
683 static const u64 headerSize = sizeof(SChunkHeader); 683 static const u64 headerSize = sizeof(SChunkHeader);
684 if (fileSize < headerSize) 684 if (fileSize < headerSize)
685 { 685 {
@@ -687,7 +687,7 @@ public:
687 return ERROR_BAD_FILE; 687 return ERROR_BAD_FILE;
688 } 688 }
689 689
690 File::IOFile pFile(_rFilename, "rb"); 690 FileUtil::IOFile pFile(_rFilename, "rb");
691 if (!pFile) 691 if (!pFile)
692 { 692 {
693 ERROR_LOG(COMMON,"ChunkReader: Can't open file for reading"); 693 ERROR_LOG(COMMON,"ChunkReader: Can't open file for reading");
@@ -765,7 +765,7 @@ public:
765 { 765 {
766 INFO_LOG(COMMON, "ChunkReader: Writing %s" , _rFilename.c_str()); 766 INFO_LOG(COMMON, "ChunkReader: Writing %s" , _rFilename.c_str());
767 767
768 File::IOFile pFile(_rFilename, "wb"); 768 FileUtil::IOFile pFile(_rFilename, "wb");
769 if (!pFile) 769 if (!pFile)
770 { 770 {
771 ERROR_LOG(COMMON,"ChunkReader: Error opening file for write"); 771 ERROR_LOG(COMMON,"ChunkReader: Error opening file for write");
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp
index 970041007..ecfccbd66 100644
--- a/src/common/file_util.cpp
+++ b/src/common/file_util.cpp
@@ -39,7 +39,7 @@
39// This namespace has various generic functions related to files and paths. 39// This namespace has various generic functions related to files and paths.
40// The code still needs a ton of cleanup. 40// The code still needs a ton of cleanup.
41// REMEMBER: strdup considered harmful! 41// REMEMBER: strdup considered harmful!
42namespace File 42namespace FileUtil
43{ 43{
44 44
45// Remove any ending forward slashes from directory paths 45// Remove any ending forward slashes from directory paths
@@ -172,7 +172,7 @@ bool CreateFullPath(const std::string &fullPath)
172 int panicCounter = 100; 172 int panicCounter = 100;
173 INFO_LOG(COMMON, "CreateFullPath: path %s", fullPath.c_str()); 173 INFO_LOG(COMMON, "CreateFullPath: path %s", fullPath.c_str());
174 174
175 if (File::Exists(fullPath)) 175 if (FileUtil::Exists(fullPath))
176 { 176 {
177 INFO_LOG(COMMON, "CreateFullPath: path exists %s", fullPath.c_str()); 177 INFO_LOG(COMMON, "CreateFullPath: path exists %s", fullPath.c_str());
178 return true; 178 return true;
@@ -190,8 +190,8 @@ bool CreateFullPath(const std::string &fullPath)
190 190
191 // Include the '/' so the first call is CreateDir("/") rather than CreateDir("") 191 // Include the '/' so the first call is CreateDir("/") rather than CreateDir("")
192 std::string const subPath(fullPath.substr(0, position + 1)); 192 std::string const subPath(fullPath.substr(0, position + 1));
193 if (!File::IsDirectory(subPath)) 193 if (!FileUtil::IsDirectory(subPath))
194 File::CreateDir(subPath); 194 FileUtil::CreateDir(subPath);
195 195
196 // A safety check 196 // A safety check
197 panicCounter--; 197 panicCounter--;
@@ -211,7 +211,7 @@ bool DeleteDir(const std::string &filename)
211 INFO_LOG(COMMON, "DeleteDir: directory %s", filename.c_str()); 211 INFO_LOG(COMMON, "DeleteDir: directory %s", filename.c_str());
212 212
213 // check if a directory 213 // check if a directory
214 if (!File::IsDirectory(filename)) 214 if (!FileUtil::IsDirectory(filename))
215 { 215 {
216 ERROR_LOG(COMMON, "DeleteDir: Not a directory %s", filename.c_str()); 216 ERROR_LOG(COMMON, "DeleteDir: Not a directory %s", filename.c_str());
217 return false; 217 return false;
@@ -386,7 +386,7 @@ bool CreateEmptyFile(const std::string &filename)
386{ 386{
387 INFO_LOG(COMMON, "CreateEmptyFile: %s", filename.c_str()); 387 INFO_LOG(COMMON, "CreateEmptyFile: %s", filename.c_str());
388 388
389 if (!File::IOFile(filename, "wb")) 389 if (!FileUtil::IOFile(filename, "wb"))
390 { 390 {
391 ERROR_LOG(COMMON, "CreateEmptyFile: failed %s: %s", 391 ERROR_LOG(COMMON, "CreateEmptyFile: failed %s: %s",
392 filename.c_str(), GetLastErrorMsg()); 392 filename.c_str(), GetLastErrorMsg());
@@ -519,7 +519,7 @@ bool DeleteDirRecursively(const std::string &directory)
519 } 519 }
520 else 520 else
521 { 521 {
522 if (!File::Delete(newPath)) 522 if (!FileUtil::Delete(newPath))
523 { 523 {
524 #ifndef _WIN32 524 #ifndef _WIN32
525 closedir(dirp); 525 closedir(dirp);
@@ -536,7 +536,7 @@ bool DeleteDirRecursively(const std::string &directory)
536 } 536 }
537 closedir(dirp); 537 closedir(dirp);
538#endif 538#endif
539 File::DeleteDir(directory); 539 FileUtil::DeleteDir(directory);
540 540
541 return true; 541 return true;
542} 542}
@@ -546,8 +546,8 @@ void CopyDir(const std::string &source_path, const std::string &dest_path)
546{ 546{
547#ifndef _WIN32 547#ifndef _WIN32
548 if (source_path == dest_path) return; 548 if (source_path == dest_path) return;
549 if (!File::Exists(source_path)) return; 549 if (!FileUtil::Exists(source_path)) return;
550 if (!File::Exists(dest_path)) File::CreateFullPath(dest_path); 550 if (!FileUtil::Exists(dest_path)) FileUtil::CreateFullPath(dest_path);
551 551
552 struct dirent dirent, *result = NULL; 552 struct dirent dirent, *result = NULL;
553 DIR *dirp = opendir(source_path.c_str()); 553 DIR *dirp = opendir(source_path.c_str());
@@ -569,10 +569,10 @@ void CopyDir(const std::string &source_path, const std::string &dest_path)
569 { 569 {
570 source += '/'; 570 source += '/';
571 dest += '/'; 571 dest += '/';
572 if (!File::Exists(dest)) File::CreateFullPath(dest); 572 if (!FileUtil::Exists(dest)) FileUtil::CreateFullPath(dest);
573 CopyDir(source, dest); 573 CopyDir(source, dest);
574 } 574 }
575 else if (!File::Exists(dest)) File::Copy(source, dest); 575 else if (!FileUtil::Exists(dest)) FileUtil::Copy(source, dest);
576 } 576 }
577 closedir(dirp); 577 closedir(dirp);
578#endif 578#endif
@@ -660,7 +660,7 @@ const std::string& GetUserPath(const unsigned int DirIDX, const std::string &new
660#ifdef _WIN32 660#ifdef _WIN32
661 paths[D_USER_IDX] = GetExeDirectory() + DIR_SEP USERDATA_DIR DIR_SEP; 661 paths[D_USER_IDX] = GetExeDirectory() + DIR_SEP USERDATA_DIR DIR_SEP;
662#else 662#else
663 if (File::Exists(ROOT_DIR DIR_SEP USERDATA_DIR)) 663 if (FileUtil::Exists(ROOT_DIR DIR_SEP USERDATA_DIR))
664 paths[D_USER_IDX] = ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP; 664 paths[D_USER_IDX] = ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP;
665 else 665 else
666 paths[D_USER_IDX] = std::string(getenv("HOME") ? 666 paths[D_USER_IDX] = std::string(getenv("HOME") ?
@@ -688,7 +688,7 @@ const std::string& GetUserPath(const unsigned int DirIDX, const std::string &new
688 688
689 if (!newPath.empty()) 689 if (!newPath.empty())
690 { 690 {
691 if (!File::IsDirectory(newPath)) 691 if (!FileUtil::IsDirectory(newPath))
692 { 692 {
693 WARN_LOG(COMMON, "Invalid path specified %s", newPath.c_str()); 693 WARN_LOG(COMMON, "Invalid path specified %s", newPath.c_str());
694 return paths[DirIDX]; 694 return paths[DirIDX];
@@ -750,11 +750,11 @@ const std::string& GetUserPath(const unsigned int DirIDX, const std::string &new
750 750
751//std::string GetThemeDir(const std::string& theme_name) 751//std::string GetThemeDir(const std::string& theme_name)
752//{ 752//{
753// std::string dir = File::GetUserPath(D_THEMES_IDX) + theme_name + "/"; 753// std::string dir = FileUtil::GetUserPath(D_THEMES_IDX) + theme_name + "/";
754// 754//
755//#if !defined(_WIN32) 755//#if !defined(_WIN32)
756// // If theme does not exist in user's dir load from shared directory 756// // If theme does not exist in user's dir load from shared directory
757// if (!File::Exists(dir)) 757// if (!FileUtil::Exists(dir))
758// dir = SHARED_USER_DIR THEMES_DIR "/" + theme_name + "/"; 758// dir = SHARED_USER_DIR THEMES_DIR "/" + theme_name + "/";
759//#endif 759//#endif
760// 760//
@@ -763,12 +763,12 @@ const std::string& GetUserPath(const unsigned int DirIDX, const std::string &new
763 763
764bool WriteStringToFile(bool text_file, const std::string &str, const char *filename) 764bool WriteStringToFile(bool text_file, const std::string &str, const char *filename)
765{ 765{
766 return File::IOFile(filename, text_file ? "w" : "wb").WriteBytes(str.data(), str.size()); 766 return FileUtil::IOFile(filename, text_file ? "w" : "wb").WriteBytes(str.data(), str.size());
767} 767}
768 768
769bool ReadFileToString(bool text_file, const char *filename, std::string &str) 769bool ReadFileToString(bool text_file, const char *filename, std::string &str)
770{ 770{
771 File::IOFile file(filename, text_file ? "r" : "rb"); 771 FileUtil::IOFile file(filename, text_file ? "r" : "rb");
772 auto const f = file.GetHandle(); 772 auto const f = file.GetHandle();
773 773
774 if (!f) 774 if (!f)
@@ -854,7 +854,7 @@ void IOFile::SetHandle(std::FILE* file)
854u64 IOFile::GetSize() 854u64 IOFile::GetSize()
855{ 855{
856 if (IsOpen()) 856 if (IsOpen())
857 return File::GetSize(m_file); 857 return FileUtil::GetSize(m_file);
858 else 858 else
859 return 0; 859 return 0;
860} 860}
diff --git a/src/common/file_util.h b/src/common/file_util.h
index 8efff4958..897cbd77e 100644
--- a/src/common/file_util.h
+++ b/src/common/file_util.h
@@ -43,7 +43,7 @@ enum {
43 NUM_PATH_INDICES 43 NUM_PATH_INDICES
44}; 44};
45 45
46namespace File 46namespace FileUtil
47{ 47{
48 48
49// FileSystem tree node/ 49// FileSystem tree node/
diff --git a/src/common/log_manager.cpp b/src/common/log_manager.cpp
index 43346f279..28b72fa20 100644
--- a/src/common/log_manager.cpp
+++ b/src/common/log_manager.cpp
@@ -75,7 +75,7 @@ LogManager::LogManager()
75 m_Log[LogTypes::MEMCARD_MANAGER] = new LogContainer("MemCard Manager", "MemCard Manager"); 75 m_Log[LogTypes::MEMCARD_MANAGER] = new LogContainer("MemCard Manager", "MemCard Manager");
76 m_Log[LogTypes::NETPLAY] = new LogContainer("NETPLAY", "Netplay"); 76 m_Log[LogTypes::NETPLAY] = new LogContainer("NETPLAY", "Netplay");
77 77
78 m_fileLog = new FileLogListener(File::GetUserPath(F_MAINLOG_IDX).c_str()); 78 m_fileLog = new FileLogListener(FileUtil::GetUserPath(F_MAINLOG_IDX).c_str());
79 m_consoleLog = new ConsoleListener(); 79 m_consoleLog = new ConsoleListener();
80 m_debuggerLog = new DebuggerLogListener(); 80 m_debuggerLog = new DebuggerLogListener();
81 81
diff --git a/src/core/loader/elf.cpp b/src/core/loader/elf.cpp
index 76c9d6d54..389d5a8c9 100644
--- a/src/core/loader/elf.cpp
+++ b/src/core/loader/elf.cpp
@@ -351,7 +351,7 @@ ResultStatus AppLoader_ELF::Load() {
351 if (is_loaded) 351 if (is_loaded)
352 return ResultStatus::ErrorAlreadyLoaded; 352 return ResultStatus::ErrorAlreadyLoaded;
353 353
354 File::IOFile file(filename, "rb"); 354 FileUtil::IOFile file(filename, "rb");
355 355
356 if (file.IsOpen()) { 356 if (file.IsOpen()) {
357 u32 size = (u32)file.GetSize(); 357 u32 size = (u32)file.GetSize();
diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp
index 577a2297a..a268e021a 100644
--- a/src/core/loader/loader.cpp
+++ b/src/core/loader/loader.cpp
@@ -78,7 +78,7 @@ ResultStatus LoadFile(const std::string& filename) {
78 { 78 {
79 INFO_LOG(LOADER, "Loading BIN file %s...", filename.c_str()); 79 INFO_LOG(LOADER, "Loading BIN file %s...", filename.c_str());
80 80
81 File::IOFile file(filename, "rb"); 81 FileUtil::IOFile file(filename, "rb");
82 82
83 if (file.IsOpen()) { 83 if (file.IsOpen()) {
84 file.ReadBytes(Memory::GetPointer(Memory::EXEFS_CODE_VADDR), (size_t)file.GetSize()); 84 file.ReadBytes(Memory::GetPointer(Memory::EXEFS_CODE_VADDR), (size_t)file.GetSize());
diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp
index 9af59e419..1e5501e6d 100644
--- a/src/core/loader/ncch.cpp
+++ b/src/core/loader/ncch.cpp
@@ -138,7 +138,7 @@ ResultStatus AppLoader_NCCH::LoadExec() const {
138 */ 138 */
139ResultStatus AppLoader_NCCH::LoadSectionExeFS(const char* name, std::vector<u8>& buffer) const { 139ResultStatus AppLoader_NCCH::LoadSectionExeFS(const char* name, std::vector<u8>& buffer) const {
140 // Iterate through the ExeFs archive until we find the .code file... 140 // Iterate through the ExeFs archive until we find the .code file...
141 File::IOFile file(filename, "rb"); 141 FileUtil::IOFile file(filename, "rb");
142 if (file.IsOpen()) { 142 if (file.IsOpen()) {
143 for (int i = 0; i < kMaxSections; i++) { 143 for (int i = 0; i < kMaxSections; i++) {
144 // Load the specified section... 144 // Load the specified section...
@@ -199,7 +199,7 @@ ResultStatus AppLoader_NCCH::Load() {
199 if (is_loaded) 199 if (is_loaded)
200 return ResultStatus::ErrorAlreadyLoaded; 200 return ResultStatus::ErrorAlreadyLoaded;
201 201
202 File::IOFile file(filename, "rb"); 202 FileUtil::IOFile file(filename, "rb");
203 if (file.IsOpen()) { 203 if (file.IsOpen()) {
204 file.ReadBytes(&ncch_header, sizeof(NCCH_Header)); 204 file.ReadBytes(&ncch_header, sizeof(NCCH_Header));
205 205
@@ -290,7 +290,7 @@ ResultStatus AppLoader_NCCH::ReadLogo(std::vector<u8>& buffer) const {
290 * @return ResultStatus result of function 290 * @return ResultStatus result of function
291 */ 291 */
292ResultStatus AppLoader_NCCH::ReadRomFS(std::vector<u8>& buffer) const { 292ResultStatus AppLoader_NCCH::ReadRomFS(std::vector<u8>& buffer) const {
293 File::IOFile file(filename, "rb"); 293 FileUtil::IOFile file(filename, "rb");
294 if (file.IsOpen()) { 294 if (file.IsOpen()) {
295 // Check if the NCCH has a RomFS... 295 // Check if the NCCH has a RomFS...
296 if (ncch_header.romfs_offset != 0 && ncch_header.romfs_size != 0) { 296 if (ncch_header.romfs_offset != 0 && ncch_header.romfs_size != 0) {
diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp
index 48e6dd182..8f4aa0ad0 100644
--- a/src/video_core/debug_utils/debug_utils.cpp
+++ b/src/video_core/debug_utils/debug_utils.cpp
@@ -336,7 +336,7 @@ void DumpTexture(const Pica::Regs::TextureConfig& texture_config, u8* data) {
336 png_infop info_ptr = nullptr; 336 png_infop info_ptr = nullptr;
337 337
338 // Open file for writing (binary mode) 338 // Open file for writing (binary mode)
339 File::IOFile fp(filename, "wb"); 339 FileUtil::IOFile fp(filename, "wb");
340 340
341 // Initialize write structure 341 // Initialize write structure
342 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr); 342 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);