]> git.lizzy.rs Git - minetest.git/blobdiff - src/filesys.h
Add minetest.get_objects_in_area (#10668)
[minetest.git] / src / filesys.h
index 19fcbb6734a3dc5281ee7abdcf1ef4fba69ed348..b2c800c55e54621c20c445755ec207066c74d8ed 100644 (file)
@@ -17,9 +17,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
 
-#ifndef FILESYS_HEADER
-#define FILESYS_HEADER
+#pragma once
 
+#include <set>
 #include <string>
 #include <vector>
 #include "exceptions.h"
@@ -27,11 +27,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #ifdef _WIN32 // WINDOWS
 #define DIR_DELIM "\\"
 #define DIR_DELIM_CHAR '\\'
-#define FILESYS_CASE_INSENSITIVE 1
+#define FILESYS_CASE_INSENSITIVE true
+#define PATH_DELIM ";"
 #else // POSIX
 #define DIR_DELIM "/"
 #define DIR_DELIM_CHAR '/'
-#define FILESYS_CASE_INSENSITIVE 0
+#define FILESYS_CASE_INSENSITIVE false
+#define PATH_DELIM ":"
 #endif
 
 namespace fs
@@ -65,10 +67,23 @@ bool DeleteSingleFileOrEmptyDirectory(const std::string &path);
 // Returns path to temp directory, can return "" on error
 std::string TempPath();
 
+/* Returns a list of subdirectories, including the path itself, but excluding
+       hidden directories (whose names start with . or _)
+*/
+void GetRecursiveDirs(std::vector<std::string> &dirs, const std::string &dir);
+std::vector<std::string> GetRecursiveDirs(const std::string &dir);
+
 /* Multiplatform */
 
-// The path itself not included
-void GetRecursiveSubPaths(const std::string &path, std::vector<std::string> &dst);
+/* The path itself not included, returns a list of all subpaths.
+   dst - vector that contains all the subpaths.
+   list files - include files in the list of subpaths.
+   ignore - paths that start with these charcters will not be listed.
+*/
+void GetRecursiveSubPaths(const std::string &path,
+                 std::vector<std::string> &dst,
+                 bool list_files,
+                 const std::set<char> &ignore = {});
 
 // Tries to delete all, returns false if any failed
 bool DeletePaths(const std::vector<std::string> &paths);
@@ -113,7 +128,8 @@ const char *GetFilenameFromPath(const char *path);
 
 bool safeWriteToFile(const std::string &path, const std::string &content);
 
-} // namespace fs
+bool ReadFile(const std::string &path, std::string &out);
 
-#endif
+bool Rename(const std::string &from, const std::string &to);
 
+} // namespace fs