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 <filesystem>
4#include <efsw/efsw.h>
5#include "FileDirectory.hpp"
6
7namespace Grindstone::Editor {
8 class FileManager {
9 public:
10 void WatchDirectory(std::string_view mountPoint, const std::filesystem::path& projectPath);
11 Directory& GetPrimaryDirectory();
12
13 virtual bool TryGetPathWithMountPoint(const std::filesystem::path& path, std::filesystem::path& outMountedPath) const;
14
15 void HandleAddPath(std::filesystem::directory_entry directoryEntry);
16 void HandleAddFolder(std::filesystem::directory_entry folderPath);
17 void HandleAddMetaFile(std::filesystem::directory_entry filePath);
18 void HandleAddFile(std::filesystem::directory_entry filePath);
19
20 void HandleModifyPath(std::filesystem::directory_entry directoryEntry);
21 void HandleModifyFolder(std::filesystem::directory_entry folderPath);
22 void HandleModifyMetaFile(std::filesystem::directory_entry filePath);
23 void HandleModifyFile(std::filesystem::directory_entry filePath);
24
25 void HandleMovePath(std::filesystem::directory_entry directoryEntry, std::string oldFilename);
26 void HandleMoveFolder(std::filesystem::directory_entry folderPath, std::string oldFilename);
27 void HandleMoveMetaFile(std::filesystem::directory_entry filePath, std::string oldFilename);
28 void HandleMoveFile(std::filesystem::directory_entry filePath, std::string oldFilename);
29
30 void HandleDeletePath(std::filesystem::directory_entry directoryEntry);
31 void HandleDeleteFolder(std::filesystem::directory_entry folderPath);
32 void HandleDeleteMetaFile(std::filesystem::directory_entry filePath);
33 void HandleDeleteFile(std::filesystem::directory_entry filePath);
34 private:
35 using FolderIterator = std::vector<Directory*>::iterator;
36 using FileIterator = std::vector<File*>::iterator;
37 FolderIterator GetSubdirectoryInDirectory(Directory* directory, std::string filename);
38 FileIterator GetFileInDirectory(Directory* directory, std::string filename);
39 Directory* GetOrMakeSubdirectory(Directory* currentDirectory, std::string subdirectoryName);
40 Directory* GetFolderForPath(std::filesystem::path path);
41 void CreateInitialFileStructure(Directory& directory, std::filesystem::directory_iterator directoryIterator);
42 bool CheckIfCompiledFileNeedsToBeUpdated(std::filesystem::path path);
43 void UpdateCompiledFileIfNecessaryOnInitialize(std::filesystem::path path);
44 void UpdateCompiledFileIfNecessary(std::filesystem::path path);
45 void RemoveFileFromManager(std::filesystem::directory_entry);
46 std::filesystem::directory_entry GetFileFromMetaPath(std::filesystem::directory_entry);
47
48 struct MountPoint {
49 efsw_watchid watchID;
50 std::string mountPoint;
51 Directory rootDirectory;
52 };
53
54 std::vector<MountPoint> mountedDirectories;
55 };
56}
Definition FileManager.hpp:8
Definition FileDirectory.hpp:19