Grindstone Game Engine v0.2.0
An open source game engine and toolkit.
Loading...
Searching...
No Matches
FileManager.hpp
1#pragma once
2
3#include <set>
4#include <filesystem>
5#include <efsw/efsw.h>
6
7namespace Grindstone::Editor {
8 class FileManager {
9 public:
10 struct MountPoint {
11 efsw_watchid watchID;
12 std::string mountPoint;
13 std::filesystem::path path;
14 };
15
16 void MountDirectory(
17 std::string_view mountPoint,
18 const std::filesystem::path& projectPath
19 );
20
21 void UnmountDirectory(
22 std::string_view mountPoint
23 );
24
25 void Initialize();
26 const std::vector<MountPoint>& GetMountedDirectories() const;
27 const FileManager::MountPoint& GetPrimaryMountPoint() const;
28 void DispatchTask(const std::filesystem::path& path) const;
29 virtual bool TryGetPathWithMountPoint(
30 const std::filesystem::path& path,
31 std::filesystem::path& outMountedPath
32 ) const;
33
34 virtual bool TryGetAbsolutePathFromMountedPath(
35 const std::filesystem::path& mountedPath,
36 std::filesystem::path& outAbsolutePath) const;
37
38 void CleanupStaleFiles();
39
40 void HandleAddMetaFile(const MountPoint& mountPoint, const std::filesystem::directory_entry& filePath);
41 void HandleAddFile(const MountPoint& mountPoint, const std::filesystem::directory_entry& filePath);
42
43 void HandleModifyMetaFile(const MountPoint& mountPoint, const std::filesystem::directory_entry& filePath);
44 void HandleModifyFile(const MountPoint& mountPoint, const std::filesystem::directory_entry& filePath);
45
46 void HandleMoveMetaFile(const MountPoint& mountPoint, const std::filesystem::directory_entry& filePath, std::string oldFilename);
47 void HandleMoveFile(const MountPoint& mountPoint, const std::filesystem::directory_entry& filePath, std::string oldFilename);
48
49 void HandleDeleteMetaFile(const MountPoint& mountPoint, const std::filesystem::directory_entry& filePath);
50 void HandleDeleteFile(const MountPoint& mountPoint, const std::filesystem::directory_entry& filePath);
51 private:
52 void PreprocessFilesOnMount(
53 const MountPoint& mountPoint,
54 std::filesystem::directory_iterator directoryIterator
55 ) const;
56
57 void DiscoverFilesOnMount(
58 const MountPoint& mountPoint,
59 std::filesystem::directory_iterator directoryIterator);
60
61 bool CheckIfCompiledFileNeedsToBeUpdated(
62 const MountPoint& mountPoint,
63 const std::filesystem::path& path
64 ) const;
65
66 void DiscoverFile(const MountPoint& mountPoint, const std::filesystem::path& path);
67 void UpdateCompiledFileIfNecessary(const MountPoint& mountPoint, const std::filesystem::path& path) const;
68 std::filesystem::directory_entry GetFileFromMetaPath(const std::filesystem::directory_entry& entry);
69
70 efsw_watcher watcher;
71 std::vector<MountPoint> mountedDirectories;
72 std::vector<std::filesystem::path> filesToImport;
73 };
74}
Definition FileManager.hpp:8
Definition AssetRegistry.hpp:13
Definition FileManager.hpp:10