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 WatchDirectory(
17 std::string_view mountPoint,
18 const std::filesystem::path& projectPath
19 );
20
21 const std::vector<MountPoint>& GetMountedDirectories() const;
22 const FileManager::MountPoint& GetPrimaryMountPoint() const;
23 void DispatchTask(const std::filesystem::path& path) const;
24 virtual bool TryGetPathWithMountPoint(
25 const std::filesystem::path& path,
26 std::filesystem::path& outMountedPath
27 ) const;
28
29 virtual bool TryGetAbsolutePathFromMountedPath(
30 const std::filesystem::path& mountedPath,
31 std::filesystem::path& outAbsolutePath
32 ) const;
33
34 void CleanupStaleFiles();
35
36 void HandleAddMetaFile(const MountPoint& mountPoint, const std::filesystem::directory_entry& filePath);
37 void HandleAddFile(const MountPoint& mountPoint, const std::filesystem::directory_entry& filePath);
38
39 void HandleModifyMetaFile(const MountPoint& mountPoint, const std::filesystem::directory_entry& filePath);
40 void HandleModifyFile(const MountPoint& mountPoint, const std::filesystem::directory_entry& filePath);
41
42 void HandleMoveMetaFile(const MountPoint& mountPoint, const std::filesystem::directory_entry& filePath, std::string oldFilename);
43 void HandleMoveFile(const MountPoint& mountPoint, const std::filesystem::directory_entry& filePath, std::string oldFilename);
44
45 void HandleDeleteMetaFile(const MountPoint& mountPoint, const std::filesystem::directory_entry& filePath);
46 void HandleDeleteFile(const MountPoint& mountPoint, const std::filesystem::directory_entry& filePath);
47 private:
48 void PreprocessFilesOnMount(
49 const MountPoint& mountPoint,
50 std::filesystem::directory_iterator directoryIterator
51 ) const;
52 bool CheckIfCompiledFileNeedsToBeUpdated(const MountPoint& mountPoint, const std::filesystem::path& path) const;
53 void UpdateCompiledFileIfNecessary(const MountPoint& mountPoint, const std::filesystem::path& path) const;
54 std::filesystem::directory_entry GetFileFromMetaPath(const std::filesystem::directory_entry& entry);
55
56 std::vector<MountPoint> mountedDirectories;
57 };
58}
Definition FileManager.hpp:8
Definition FileManager.hpp:10