77#include < vector>
88
99namespace sorbet {
10+ class WorkerPool ;
1011
1112class FileOps final {
1213public:
@@ -16,36 +17,42 @@ class FileOps final {
1617 std::optional<std::string> output = std::nullopt ;
1718 };
1819
19- static bool exists (std::string_view filename);
20+ static bool exists (const std::string & filename);
2021 static bool isFile (std::string_view path, std::string_view ignorePattern, const int pos);
2122 static bool isFolder (std::string_view path, std::string_view ignorePattern, const int pos);
22- static std::string read (std::string_view filename);
23- static void write (std::string_view filename, const std::vector<uint8_t > &data);
24- static void append (std::string_view filename, std::string_view text);
25- static void write (std::string_view filename, std::string_view text);
26- static bool writeIfDifferent (std::string_view filename, std::string_view text);
27- static bool dirExists (std::string_view path);
28- static void createDir (std::string_view path);
23+ static std::string read (const std::string & filename);
24+ static void write (const std::string & filename, const std::vector<uint8_t > &data);
25+ static void append (const std::string & filename, std::string_view text);
26+ static void write (const std::string & filename, std::string_view text);
27+ static bool writeIfDifferent (const std::string & filename, std::string_view text);
28+ static bool dirExists (const std::string & path);
29+ static void createDir (const std::string & path);
2930
3031 // This differs from createDir, as it will not raise an exception if the directory already exists. Returns true when
3132 // the directory was created, and false if it already existed.
3233 //
3334 // NOTE: This does not create parent directories if they exist.
34- static bool ensureDir (std::string_view path);
35+ static bool ensureDir (const std::string & path);
3536
3637 static std::string getCurrentDir ();
3738
3839 // NOTE: this is a minimal wrapper around rmdir, and as such will raise an exception if the directory is not empty
3940 // when it's removed.
40- static void removeDir (std::string_view path);
41+ static void removeDir (const std::string &path);
42+
43+ // NOTE: this is a minimal wrapper around rmdir, and will return false if the directory is not empty
44+ // when it's removed. For any other errno, it will throw an exception. This exists as an convenience function to
45+ // prevent the caller from needing to try/catch removeDir.
46+ static bool removeEmptyDir (const std::string &path);
47+
48+ static void removeFile (const std::string &path);
4149
42- static void removeFile (std::string_view path);
4350 /* *
4451 * Returns a list of all files in the given directory. Returns paths that include the path to directory.
4552 * Throws FileNotFoundException if path does not exist, and FileNotDirException if path is not a directory.
4653 */
4754 static std::vector<std::string> listFilesInDir (std::string_view path, const UnorderedSet<std::string> &extensions,
48- bool recursive,
55+ WorkerPool &workers, bool recursive,
4956 const std::vector<std::string> &absoluteIgnorePatterns,
5057 const std::vector<std::string> &relativeIgnorePatterns);
5158 /* *
0 commit comments