From 9059147974ffbe2bea55b9c2136307a77f465835 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sat, 15 Jan 2022 22:45:11 +0000 Subject: Replace uses of the FileSystem class with std::filesystem. --- src/fileutils.cpp | 44 -------------------------------------------- 1 file changed, 44 deletions(-) (limited to 'src/fileutils.cpp') 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] == ':'); -} -- cgit v1.3.1-10-gc9f91