diff options
| author | 2022-01-15 22:45:11 +0000 | |
|---|---|---|
| committer | 2022-01-15 23:20:45 +0000 | |
| commit | 9059147974ffbe2bea55b9c2136307a77f465835 (patch) | |
| tree | dd5e8a4a0634d4a9afbf14813c8779f7839f99f5 /src/fileutils.cpp | |
| parent | Merge branch 'insp3' into master. (diff) | |
Replace uses of the FileSystem class with std::filesystem.
Diffstat (limited to 'src/fileutils.cpp')
| -rw-r--r-- | src/fileutils.cpp | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/src/fileutils.cpp b/src/fileutils.cpp index fa600f306..7f36b4b24 100644 --- a/src/fileutils.cpp +++ b/src/fileutils.cpp @@ -79,47 +79,3 @@ std::string FileReader::GetString() const } return buffer; } - -std::string FileSystem::ExpandPath(const std::string& base, const std::string& fragment) -{ - // The fragment is an absolute path, don't modify it. - if (fragment[0] == '/' || FileSystem::StartsWithWindowsDriveLetter(fragment)) - return fragment; - - // The fragment is relative to a home directory, expand that. - if (!fragment.compare(0, 2, "~/", 2)) - { - const char* homedir = getenv("HOME"); - if (homedir && *homedir) - return std::string(homedir) + '/' + fragment.substr(2); - } - - return base + '/' + fragment; -} - -bool FileSystem::FileExists(const std::string& file) -{ - struct stat sb; - if (stat(file.c_str(), &sb) == -1) - return false; - - if ((sb.st_mode & S_IFDIR) > 0) - return false; - - return !access(file.c_str(), F_OK); -} - -std::string FileSystem::GetFileName(const std::string& name) -{ -#ifdef _WIN32 - size_t pos = name.find_last_of("\\/"); -#else - size_t pos = name.rfind('/'); -#endif - return pos == std::string::npos ? name : name.substr(++pos); -} - -bool FileSystem::StartsWithWindowsDriveLetter(const std::string& path) -{ - return (path.length() > 2 && isalpha(path[0]) && path[1] == ':'); -} |
