Etterna 0.74.4
Loading...
Searching...
No Matches
RageFileManager.h
1#ifndef RAGE_FILE_MANAGER_H
2#define RAGE_FILE_MANAGER_H
3
4#include <string>
5#include <vector>
6
9extern std::string sInitialWorkingDirectory;
10extern std::string sDirOfExecutable;
11}
12
13class RageFileDriver;
14class RageFileBasic;
15struct lua_State;
16
17auto
18ilt(const std::string& a, const std::string& b) -> bool;
19auto
20ieq(const std::string& a, const std::string& b) -> bool;
21
22enum DirListingReturnFilter
23{
24 ANY_TYPE = 0,
25 ONLY_DIR = 1,
26 ONLY_FILE = 2,
27};
28
31{
32 public:
33 RageFileManager(const std::string& argv0);
35
36 void GetDirListing(const std::string& sPath,
37 std::vector<std::string>& AddTo,
38 DirListingReturnFilter dirListingFilter = ANY_TYPE,
39 bool bReturnPathToo = false);
40
41 void GetDirListingWithMultipleExtensions(
42 const std::string& sPath,
43 std::vector<std::string> const& ExtensionList,
44 std::vector<std::string>& AddTo,
45 DirListingReturnFilter dirListingFilter = ANY_TYPE,
46 bool bReturnPathToo = false);
47
48 // compatibility ....
49 void GetDirListing(const std::string& sPath,
50 std::vector<std::string>& AddTo,
51 bool dirOnly,
52 bool bReturnPathToo)
53 {
54 GetDirListing(
55 sPath, AddTo, dirOnly ? ONLY_DIR : ANY_TYPE, bReturnPathToo);
56 }
57
58 // compatibility ....
59 void GetDirListingWithMultipleExtensions(
60 const std::string& sPath,
61 std::vector<std::string> const& ExtensionList,
62 std::vector<std::string>& AddTo,
63 bool dirOnly,
64 bool bReturnPathToo)
65 {
66 GetDirListingWithMultipleExtensions(sPath,
67 ExtensionList,
68 AddTo,
69 dirOnly ? ONLY_DIR : ANY_TYPE,
70 bReturnPathToo);
71 }
72
73 auto Move(const std::string& sOldPath, const std::string& sNewPath) -> bool;
74 auto Remove(const std::string& sPath) -> bool;
75 void CreateDir(const std::string& sDir);
76
77 enum FileType
78 {
79 TYPE_FILE,
80 TYPE_DIR,
81 TYPE_NONE
82 };
83 auto GetFileType(const std::string& sPath) -> FileType;
84
85 auto IsAFile(const std::string& sPath) -> bool;
86 auto IsADirectory(const std::string& sPath) -> bool;
87 auto DoesFileExist(const std::string& sPath) -> bool;
88
89 auto GetFileSizeInBytes(const std::string& sPath) -> int;
90 auto GetFileHash(const std::string& sPath) -> int;
91
96 auto ResolvePath(const std::string& path) -> std::string;
97
98 // This function fails if the path given is in AdditionalSongs
99 // when using multiple AdditionalSongs mount points
100 auto ResolveSongFolder(const std::string& path,
101 bool additionalSongs = false) -> std::string;
102
103 auto Mount(const std::string& sType,
104 const std::string& sRealPath,
105 const std::string& sMountPoint,
106 bool bAddToEnd = true) -> bool;
107 void Mount(RageFileDriver* pDriver,
108 const std::string& sMountPoint,
109 bool bAddToEnd = true);
110 void Unmount(const std::string& sType,
111 const std::string& sRoot,
112 const std::string& sMountPoint);
113
114 /* Change the root of a filesystem. Only a couple drivers support this;
115 * it's used to change memory card mountpoints without having to actually
116 * unmount the driver. */
117 void Remount(const std::string& sMountpoint, const std::string& sPath);
118 auto IsMounted(const std::string& MountPoint) -> bool;
120 {
121 std::string Type, Root, MountPoint;
122 };
123 void GetLoadedDrivers(std::vector<DriverLocation>& asMounts);
124
125 void FlushDirCache(const std::string& sPath = std::string());
126
127 /* Used only by RageFile: */
128 auto Open(const std::string& sPath, int iMode, int& iError)
129 -> RageFileBasic*;
130 void CacheFile(const RageFileBasic* fb, const std::string& sPath);
131
132 /* Retrieve or release a reference to the low-level driver for a mountpoint.
133 */
134 auto GetFileDriver(std::string sMountpoint) -> RageFileDriver*;
135 void ReleaseFileDriver(RageFileDriver* pDriver);
136
137 // Lua
138 void PushSelf(lua_State* L);
139
140 private:
141 auto OpenForReading(const std::string& sPath, int iMode, int& iError)
142 -> RageFileBasic*;
143 auto OpenForWriting(const std::string& sPath, int iMode, int& iError)
144 -> RageFileBasic*;
145};
146
147extern RageFileManager* FILEMAN;
148
149#endif
Definition RageFileBasic.h:10
Definition RageFileDriver.h:12
File utilities and high-level manager for RageFile objects.
Definition RageFileManager.h:31
auto ResolvePath(const std::string &path) -> std::string
Get the absolte path from the VPS.
Definition RageFileManager.cpp:889
Constants for working with the RageFileManager.
Definition RageFileManager.h:8
Definition RageFileManager.h:120