forked from ShuriZma/suyu
common/file_util: Remove duplicated documentation comments
These are already present within the header, so they don't need to be repeated in the cpp file.
This commit is contained in:
parent
2b1fcc8a14
commit
943f6da1ac
|
@ -87,7 +87,6 @@ static void StripTailDirSlashes(std::string& fname) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if file filename exists
|
|
||||||
bool Exists(const std::string& filename) {
|
bool Exists(const std::string& filename) {
|
||||||
struct stat file_info;
|
struct stat file_info;
|
||||||
|
|
||||||
|
@ -107,7 +106,6 @@ bool Exists(const std::string& filename) {
|
||||||
return (result == 0);
|
return (result == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if filename is a directory
|
|
||||||
bool IsDirectory(const std::string& filename) {
|
bool IsDirectory(const std::string& filename) {
|
||||||
struct stat file_info;
|
struct stat file_info;
|
||||||
|
|
||||||
|
@ -132,8 +130,6 @@ bool IsDirectory(const std::string& filename) {
|
||||||
return S_ISDIR(file_info.st_mode);
|
return S_ISDIR(file_info.st_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deletes a given filename, return true on success
|
|
||||||
// Doesn't supports deleting a directory
|
|
||||||
bool Delete(const std::string& filename) {
|
bool Delete(const std::string& filename) {
|
||||||
LOG_TRACE(Common_Filesystem, "file {}", filename);
|
LOG_TRACE(Common_Filesystem, "file {}", filename);
|
||||||
|
|
||||||
|
@ -165,7 +161,6 @@ bool Delete(const std::string& filename) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if successful, or path already exists.
|
|
||||||
bool CreateDir(const std::string& path) {
|
bool CreateDir(const std::string& path) {
|
||||||
LOG_TRACE(Common_Filesystem, "directory {}", path);
|
LOG_TRACE(Common_Filesystem, "directory {}", path);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -194,7 +189,6 @@ bool CreateDir(const std::string& path) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates the full path of fullPath returns true on success
|
|
||||||
bool CreateFullPath(const std::string& fullPath) {
|
bool CreateFullPath(const std::string& fullPath) {
|
||||||
int panicCounter = 100;
|
int panicCounter = 100;
|
||||||
LOG_TRACE(Common_Filesystem, "path {}", fullPath);
|
LOG_TRACE(Common_Filesystem, "path {}", fullPath);
|
||||||
|
@ -230,7 +224,6 @@ bool CreateFullPath(const std::string& fullPath) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deletes a directory filename, returns true on success
|
|
||||||
bool DeleteDir(const std::string& filename) {
|
bool DeleteDir(const std::string& filename) {
|
||||||
LOG_TRACE(Common_Filesystem, "directory {}", filename);
|
LOG_TRACE(Common_Filesystem, "directory {}", filename);
|
||||||
|
|
||||||
|
@ -252,7 +245,6 @@ bool DeleteDir(const std::string& filename) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// renames file srcFilename to destFilename, returns true on success
|
|
||||||
bool Rename(const std::string& srcFilename, const std::string& destFilename) {
|
bool Rename(const std::string& srcFilename, const std::string& destFilename) {
|
||||||
LOG_TRACE(Common_Filesystem, "{} --> {}", srcFilename, destFilename);
|
LOG_TRACE(Common_Filesystem, "{} --> {}", srcFilename, destFilename);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -268,7 +260,6 @@ bool Rename(const std::string& srcFilename, const std::string& destFilename) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// copies file srcFilename to destFilename, returns true on success
|
|
||||||
bool Copy(const std::string& srcFilename, const std::string& destFilename) {
|
bool Copy(const std::string& srcFilename, const std::string& destFilename) {
|
||||||
LOG_TRACE(Common_Filesystem, "{} --> {}", srcFilename, destFilename);
|
LOG_TRACE(Common_Filesystem, "{} --> {}", srcFilename, destFilename);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -324,7 +315,6 @@ bool Copy(const std::string& srcFilename, const std::string& destFilename) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the size of filename (64bit)
|
|
||||||
u64 GetSize(const std::string& filename) {
|
u64 GetSize(const std::string& filename) {
|
||||||
if (!Exists(filename)) {
|
if (!Exists(filename)) {
|
||||||
LOG_ERROR(Common_Filesystem, "failed {}: No such file", filename);
|
LOG_ERROR(Common_Filesystem, "failed {}: No such file", filename);
|
||||||
|
@ -351,7 +341,6 @@ u64 GetSize(const std::string& filename) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Overloaded GetSize, accepts file descriptor
|
|
||||||
u64 GetSize(const int fd) {
|
u64 GetSize(const int fd) {
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
if (fstat(fd, &buf) != 0) {
|
if (fstat(fd, &buf) != 0) {
|
||||||
|
@ -361,7 +350,6 @@ u64 GetSize(const int fd) {
|
||||||
return buf.st_size;
|
return buf.st_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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);
|
u64 pos = ftello(f);
|
||||||
|
@ -377,7 +365,6 @@ u64 GetSize(FILE* f) {
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
// creates an empty file filename, returns true on success
|
|
||||||
bool CreateEmptyFile(const std::string& filename) {
|
bool CreateEmptyFile(const std::string& filename) {
|
||||||
LOG_TRACE(Common_Filesystem, "{}", filename);
|
LOG_TRACE(Common_Filesystem, "{}", filename);
|
||||||
|
|
||||||
|
@ -502,7 +489,6 @@ bool DeleteDirRecursively(const std::string& directory, unsigned int recursion)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create directory and copy contents (does not overwrite existing files)
|
|
||||||
void CopyDir(const std::string& source_path, const std::string& dest_path) {
|
void CopyDir(const std::string& source_path, const std::string& dest_path) {
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
if (source_path == dest_path)
|
if (source_path == dest_path)
|
||||||
|
@ -539,7 +525,6 @@ void CopyDir(const std::string& source_path, const std::string& dest_path) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the current directory
|
|
||||||
std::string GetCurrentDir() {
|
std::string GetCurrentDir() {
|
||||||
// Get the current working directory (getcwd uses malloc)
|
// Get the current working directory (getcwd uses malloc)
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -561,7 +546,6 @@ std::string GetCurrentDir() {
|
||||||
return strDir;
|
return strDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sets the current directory to the given directory
|
|
||||||
bool SetCurrentDir(const std::string& directory) {
|
bool SetCurrentDir(const std::string& directory) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return _wchdir(Common::UTF8ToUTF16W(directory).c_str()) == 0;
|
return _wchdir(Common::UTF8ToUTF16W(directory).c_str()) == 0;
|
||||||
|
@ -673,8 +657,6 @@ std::string GetSysDirectory() {
|
||||||
return sysDir;
|
return sysDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a string with a yuzu data dir or file in the user's home
|
|
||||||
// directory. To be used in "multi-user" mode (that is, installed).
|
|
||||||
const std::string& GetUserPath(UserPath path, const std::string& new_path) {
|
const std::string& GetUserPath(UserPath path, const std::string& new_path) {
|
||||||
static std::unordered_map<UserPath, std::string> paths;
|
static std::unordered_map<UserPath, std::string> paths;
|
||||||
auto& user_path = paths[UserPath::UserDir];
|
auto& user_path = paths[UserPath::UserDir];
|
||||||
|
@ -776,13 +758,6 @@ std::size_t ReadFileToString(bool text_file, const std::string& filename, std::s
|
||||||
return file.ReadArray(&str[0], str.size());
|
return file.ReadArray(&str[0], str.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Splits the filename into 8.3 format
|
|
||||||
* Loosely implemented following https://en.wikipedia.org/wiki/8.3_filename
|
|
||||||
* @param filename The normal filename to use
|
|
||||||
* @param short_name A 9-char array in which the short name will be written
|
|
||||||
* @param extension A 4-char array in which the extension will be written
|
|
||||||
*/
|
|
||||||
void SplitFilename83(const std::string& filename, std::array<char, 9>& short_name,
|
void SplitFilename83(const std::string& filename, std::array<char, 9>& short_name,
|
||||||
std::array<char, 4>& extension) {
|
std::array<char, 4>& extension) {
|
||||||
const std::string forbidden_characters = ".\"/\\[]:;=, ";
|
const std::string forbidden_characters = ".\"/\\[]:;=, ";
|
||||||
|
|
Loading…
Reference in New Issue