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
37 ) const;
38
39 void CleanupStaleFiles();
40
41 void HandleAddMetaFile(const MountPoint& mountPoint, const std::filesystem::directory_entry& filePath);
42 void HandleAddFile(const MountPoint& mountPoint, const std::filesystem::directory_entry& filePath);
43
44 void HandleModifyMetaFile(const MountPoint& mountPoint, const std::filesystem::directory_entry& filePath);
45 void HandleModifyFile(const MountPoint& mountPoint, const std::filesystem::directory_entry& filePath);
46
47 void HandleMoveMetaFile(const MountPoint& mountPoint, const std::filesystem::directory_entry& filePath, std::string oldFilename);
48 void HandleMoveFile(const MountPoint& mountPoint, const std::filesystem::directory_entry& filePath, std::string oldFilename);
49
50 void HandleDeleteMetaFile(const MountPoint& mountPoint, const std::filesystem::directory_entry& filePath);
51 void HandleDeleteFile(const MountPoint& mountPoint, const std::filesystem::directory_entry& filePath);
52 private:
53 void PreprocessFilesOnMount(
54 const MountPoint& mountPoint,
55 std::filesystem::directory_iterator directoryIterator
56 ) const;
57 bool CheckIfCompiledFileNeedsToBeUpdated(const MountPoint& mountPoint, const std::filesystem::path& path) const;
58 void UpdateCompiledFileIfNecessary(const MountPoint& mountPoint, const std::filesystem::path& path) const;
59 std::filesystem::directory_entry GetFileFromMetaPath(const std::filesystem::directory_entry& entry);
60
61 efsw_watcher watcher;
62 std::vector<MountPoint> mountedDirectories;
63 };
64}
Definition FileManager.hpp:8
Definition FileManager.hpp:10