Commit 886014f1 authored by Ivan Dokunov's avatar Ivan Dokunov

Added FileSystem priority for paths

parent 5c6992dc

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.40629.0
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SkyXEngine", "SkyXEngine.vcxproj", "{97D8EE94-0A6D-47F2-BE01-63F7C89715BC}"
ProjectSection(ProjectDependencies) = postProject
......@@ -674,65 +674,62 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{C1C1F046-C839-4602-AF70-923CDD237C1B} = {74D74409-BAC7-4DD0-8C74-117516B4A01C}
{AEECC2DB-C7C7-4089-9262-A69794DF834D} = {74D74409-BAC7-4DD0-8C74-117516B4A01C}
{0C7E3DB7-005F-41E9-A570-868BCF959E91} = {4408F4BE-1F9D-4861-881A-AF9869C3D663}
{3A5449A3-DCE7-4557-9C9F-DEEAFBAAC763} = {74D74409-BAC7-4DD0-8C74-117516B4A01C}
{74D74409-BAC7-4DD0-8C74-117516B4A01C} = {13D5622C-8643-4BD8-A730-B5C919DAFDDC}
{E6B16854-D4A4-4B56-8E1C-482DD523F205} = {13D5622C-8643-4BD8-A730-B5C919DAFDDC}
{BA779DCC-93C8-4FB7-BBB9-A7D2F76C35DE} = {13D5622C-8643-4BD8-A730-B5C919DAFDDC}
{0292BE32-298E-4E18-BC42-5A39F9487EBA} = {13D5622C-8643-4BD8-A730-B5C919DAFDDC}
{6376944C-E417-43FD-8B56-073A310EB7D9} = {13D5622C-8643-4BD8-A730-B5C919DAFDDC}
{56A8D7F7-B73C-4206-8038-83D8A169AA2F} = {13D5622C-8643-4BD8-A730-B5C919DAFDDC}
{BE976610-EE71-4D57-8733-2FE43BF602F5} = {13D5622C-8643-4BD8-A730-B5C919DAFDDC}
{120D29B8-D2D9-4B4E-8AC6-D951973B7398} = {13D5622C-8643-4BD8-A730-B5C919DAFDDC}
{B9656841-7734-4D0B-8619-1BED5E2ED7AE} = {13D5622C-8643-4BD8-A730-B5C919DAFDDC}
{6A402480-C09B-4CBF-A6BD-115CE4BFF2D8} = {13D5622C-8643-4BD8-A730-B5C919DAFDDC}
{2D039A6D-B874-4AA7-8F89-E86DD70B21ED} = {13D5622C-8643-4BD8-A730-B5C919DAFDDC}
{236F4A16-78D8-42E4-86C0-30265CA2D84D} = {13D5622C-8643-4BD8-A730-B5C919DAFDDC}
{8C9E1225-F0B3-403E-AB88-3372E67DE173} = {13D5622C-8643-4BD8-A730-B5C919DAFDDC}
{C3CAABF6-9239-4133-86E3-44DF79A67AF6} = {13D5622C-8643-4BD8-A730-B5C919DAFDDC}
{AEECC2DB-C7C7-4089-9262-A69794DF834D} = {74D74409-BAC7-4DD0-8C74-117516B4A01C}
{3A5449A3-DCE7-4557-9C9F-DEEAFBAAC763} = {74D74409-BAC7-4DD0-8C74-117516B4A01C}
{7C0C8205-BDD3-44A3-AA3A-7855C7EFC88E} = {74D74409-BAC7-4DD0-8C74-117516B4A01C}
{718C186E-9155-41DF-B8AB-74ED03E204CD} = {74D74409-BAC7-4DD0-8C74-117516B4A01C}
{7F0ACED1-6E16-4DD3-800E-0C50150897C2} = {74D74409-BAC7-4DD0-8C74-117516B4A01C}
{8AA0585B-D6E4-46B4-9183-3BACD5B9D47F} = {74D74409-BAC7-4DD0-8C74-117516B4A01C}
{8144D5F8-07D0-4663-AAAE-11053614FAC5} = {74D74409-BAC7-4DD0-8C74-117516B4A01C}
{16D78A7B-8EE9-4FD3-84C9-B71D8723E718} = {74D74409-BAC7-4DD0-8C74-117516B4A01C}
{D2386C4E-7032-487B-8EAD-951778AD6EBC} = {74D74409-BAC7-4DD0-8C74-117516B4A01C}
{C1C1F046-C839-4602-AF70-923CDD237C1B} = {74D74409-BAC7-4DD0-8C74-117516B4A01C}
{4408F4BE-1F9D-4861-881A-AF9869C3D663} = {E6B16854-D4A4-4B56-8E1C-482DD523F205}
{7C1F0E50-7A19-4AB4-B559-11EF078F4787} = {E6B16854-D4A4-4B56-8E1C-482DD523F205}
{6FE14C5C-6052-4D96-A89F-0843D91F89AD} = {E6B16854-D4A4-4B56-8E1C-482DD523F205}
{6A3341BF-710B-4310-A7F8-810040D698DC} = {5128FBE9-1706-4255-B422-4A652320085E}
{709D8A7A-D3E0-4070-A493-EFDF7A8E9D73} = {4408F4BE-1F9D-4861-881A-AF9869C3D663}
{AFBF200A-9260-4469-AE64-DCB42C796DD6} = {5128FBE9-1706-4255-B422-4A652320085E}
{A2B9EACA-69C1-4E9D-AF3C-704608DB57DE} = {5128FBE9-1706-4255-B422-4A652320085E}
{9C34362D-7FA6-4BD1-A48B-8FDE541344B0} = {5128FBE9-1706-4255-B422-4A652320085E}
{CEFD4247-0B36-4268-B455-C1E826173005} = {5128FBE9-1706-4255-B422-4A652320085E}
{6376944C-E417-43FD-8B56-073A310EB7D9} = {13D5622C-8643-4BD8-A730-B5C919DAFDDC}
{B66C63CA-62E0-472F-9D24-070CAC7C8B12} = {5128FBE9-1706-4255-B422-4A652320085E}
{D381001E-C1FF-415F-A269-5264AD9013D5} = {5128FBE9-1706-4255-B422-4A652320085E}
{A1AC0163-A56A-416D-AFA0-19F7DFBE9F64} = {5128FBE9-1706-4255-B422-4A652320085E}
{2B3BA583-D5EC-4DC2-91CF-42B1C7ADFD9D} = {4408F4BE-1F9D-4861-881A-AF9869C3D663}
{0C7E3DB7-005F-41E9-A570-868BCF959E91} = {4408F4BE-1F9D-4861-881A-AF9869C3D663}
{709D8A7A-D3E0-4070-A493-EFDF7A8E9D73} = {4408F4BE-1F9D-4861-881A-AF9869C3D663}
{A57B87BE-C63D-C64F-A06E-C48B4723C51A} = {6376944C-E417-43FD-8B56-073A310EB7D9}
{EF2EC91D-F2A6-BD43-89AC-8054F3D5EECA} = {6376944C-E417-43FD-8B56-073A310EB7D9}
{D6ECE531-C294-BC42-8C32-6F09F1240325} = {6376944C-E417-43FD-8B56-073A310EB7D9}
{60A46FEB-576C-7B40-A047-D6079D9D66C4} = {6376944C-E417-43FD-8B56-073A310EB7D9}
{7C0C8205-BDD3-44A3-AA3A-7855C7EFC88E} = {74D74409-BAC7-4DD0-8C74-117516B4A01C}
{072A60D2-317A-CC41-AD12-7E381235064A} = {6376944C-E417-43FD-8B56-073A310EB7D9}
{46A17C83-2972-4C41-B67F-224640089085} = {6376944C-E417-43FD-8B56-073A310EB7D9}
{E74F00B5-7DC5-DC48-8E91-D1C2296F455F} = {6376944C-E417-43FD-8B56-073A310EB7D9}
{56A8D7F7-B73C-4206-8038-83D8A169AA2F} = {13D5622C-8643-4BD8-A730-B5C919DAFDDC}
{BE976610-EE71-4D57-8733-2FE43BF602F5} = {13D5622C-8643-4BD8-A730-B5C919DAFDDC}
{F2DD3789-7BC9-D241-8C8D-2179933B30DD} = {6376944C-E417-43FD-8B56-073A310EB7D9}
{ED53EB62-C809-1649-A203-948AF1412B4C} = {6376944C-E417-43FD-8B56-073A310EB7D9}
{15CBFEFF-7965-41F5-B4E2-21E8795C9159} = {BE976610-EE71-4D57-8733-2FE43BF602F5}
{CEBDE98B-A6AA-46E6-BC79-FAAF823DB9EC} = {BE976610-EE71-4D57-8733-2FE43BF602F5}
{3A214E06-B95E-4D61-A291-1F8DF2EC10FD} = {BE976610-EE71-4D57-8733-2FE43BF602F5}
{120D29B8-D2D9-4B4E-8AC6-D951973B7398} = {13D5622C-8643-4BD8-A730-B5C919DAFDDC}
{718C186E-9155-41DF-B8AB-74ED03E204CD} = {74D74409-BAC7-4DD0-8C74-117516B4A01C}
{B9656841-7734-4D0B-8619-1BED5E2ED7AE} = {13D5622C-8643-4BD8-A730-B5C919DAFDDC}
{B66C63CA-62E0-472F-9D24-070CAC7C8B12} = {5128FBE9-1706-4255-B422-4A652320085E}
{F2DD3789-7BC9-D241-8C8D-2179933B30DD} = {6376944C-E417-43FD-8B56-073A310EB7D9}
{ED53EB62-C809-1649-A203-948AF1412B4C} = {6376944C-E417-43FD-8B56-073A310EB7D9}
{6A402480-C09B-4CBF-A6BD-115CE4BFF2D8} = {13D5622C-8643-4BD8-A730-B5C919DAFDDC}
{7F0ACED1-6E16-4DD3-800E-0C50150897C2} = {74D74409-BAC7-4DD0-8C74-117516B4A01C}
{D381001E-C1FF-415F-A269-5264AD9013D5} = {5128FBE9-1706-4255-B422-4A652320085E}
{8AA0585B-D6E4-46B4-9183-3BACD5B9D47F} = {74D74409-BAC7-4DD0-8C74-117516B4A01C}
{2D039A6D-B874-4AA7-8F89-E86DD70B21ED} = {13D5622C-8643-4BD8-A730-B5C919DAFDDC}
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B} = {2D039A6D-B874-4AA7-8F89-E86DD70B21ED}
{8144D5F8-07D0-4663-AAAE-11053614FAC5} = {74D74409-BAC7-4DD0-8C74-117516B4A01C}
{2B3BA583-D5EC-4DC2-91CF-42B1C7ADFD9D} = {4408F4BE-1F9D-4861-881A-AF9869C3D663}
{236F4A16-78D8-42E4-86C0-30265CA2D84D} = {13D5622C-8643-4BD8-A730-B5C919DAFDDC}
{8C9E1225-F0B3-403E-AB88-3372E67DE173} = {13D5622C-8643-4BD8-A730-B5C919DAFDDC}
{9117FCDB-957B-4FF8-8AD4-90965159B721} = {8C9E1225-F0B3-403E-AB88-3372E67DE173}
{15AD3AF2-47B1-4836-9777-F1249EB299A7} = {8C9E1225-F0B3-403E-AB88-3372E67DE173}
{DAFA20F5-5162-4F21-99AF-DB8084D3C557} = {8C9E1225-F0B3-403E-AB88-3372E67DE173}
{A1AC0163-A56A-416D-AFA0-19F7DFBE9F64} = {5128FBE9-1706-4255-B422-4A652320085E}
{E6B16854-D4A4-4B56-8E1C-482DD523F205} = {13D5622C-8643-4BD8-A730-B5C919DAFDDC}
{7C1F0E50-7A19-4AB4-B559-11EF078F4787} = {E6B16854-D4A4-4B56-8E1C-482DD523F205}
{5145958A-F75F-4F6D-9793-7384B616CF76} = {7C1F0E50-7A19-4AB4-B559-11EF078F4787}
{F0BA654B-EFF1-4F48-8ED5-4B1AA6888687} = {C3CAABF6-9239-4133-86E3-44DF79A67AF6}
{C3CAABF6-9239-4133-86E3-44DF79A67AF6} = {13D5622C-8643-4BD8-A730-B5C919DAFDDC}
{4408F4BE-1F9D-4861-881A-AF9869C3D663} = {E6B16854-D4A4-4B56-8E1C-482DD523F205}
{16D78A7B-8EE9-4FD3-84C9-B71D8723E718} = {74D74409-BAC7-4DD0-8C74-117516B4A01C}
{D2386C4E-7032-487B-8EAD-951778AD6EBC} = {74D74409-BAC7-4DD0-8C74-117516B4A01C}
{74D74409-BAC7-4DD0-8C74-117516B4A01C} = {13D5622C-8643-4BD8-A730-B5C919DAFDDC}
{6FE14C5C-6052-4D96-A89F-0843D91F89AD} = {E6B16854-D4A4-4B56-8E1C-482DD523F205}
{FE640066-C8E8-41FB-AD13-89BC03BFFBFB} = {7C1F0E50-7A19-4AB4-B559-11EF078F4787}
EndGlobalSection
GlobalSection(Performance) = preSolution
HasPerformanceSessions = true
{F0BA654B-EFF1-4F48-8ED5-4B1AA6888687} = {C3CAABF6-9239-4133-86E3-44DF79A67AF6}
EndGlobalSection
EndGlobal
......@@ -8,6 +8,18 @@
#include <shellapi.h>
#include <ShlObj.h>
void CFileSystem::addPathInPriorityArray(int id, int iPriority)
{
Pair newElement{ iPriority, id };
if (iPriority == -1)
{
newElement.priority = m_filePaths.size() > 1 ? m_priorityArray[m_lastRootId].priority : 1;
}
m_priorityArray.push_back(newElement);
m_priorityArray.quickSort([&](const Pair &obj, const Pair &obj2) -> bool {return obj.priority < obj2.priority; });
}
bool CFileSystem::isFileOrDirectory(const char *szPath, bool isFile)
{
char* path = getAbsoluteCanonizePath(szPath);
......@@ -205,7 +217,7 @@ UINT CFileSystem::addRoot(const char *szPath, int iPriority)
str += szPath; // <--- Оптимизация для того что бы не создавать временных объектов
m_filePaths.push_back(str);
m_priority.push_back(iPriority);
addPathInPriorityArray(m_filePaths.size() - 1, iPriority);
//Если у нас некорректный путь для записи и путь не является архивным
if (m_writableRoot == -1 && *szPath != '@')
......@@ -251,9 +263,10 @@ bool CFileSystem::resolvePath(const char *szPath, char *szOut, int iOutMax)
String buff;
for (UINT i = 0, l = m_filePaths.size(); i < l; ++i)
for (UINT i = 0, l = m_priorityArray.size(); i < l; ++i)
{
buff = (m_filePaths[i] + '/' + szPath);
int id = m_priorityArray[i].pathId;
buff = (m_filePaths[id] + '/' + szPath);
if (fileExists(buff.c_str()) && isFile(buff.c_str()))
{
......
......@@ -8,14 +8,15 @@ See the license in LICENSE
#include <xcommon/IFileSystem.h>
#include <cassert>
#include <map>
#define CLOSE_HANDLE(handle) if (handle != INVALID_HANDLE_VALUE) \
#define CLOSE_HANDLE(handle) if (handle != INVALID_HANDLE_VALUE && handle != nullptr) \
{\
CloseHandle(handle); \
handle = nullptr; \
}
#define FIND_CLOSE(handle) if (handle != INVALID_HANDLE_VALUE) \
#define FIND_CLOSE(handle) if (handle != INVALID_HANDLE_VALUE && handle != nullptr) \
{\
FindClose(handle); \
handle = nullptr; \
......@@ -36,6 +37,12 @@ See the license in LICENSE
assert(size - 1 < id && "The path ID you entered does not exist"); \
}
struct Pair
{
int priority;
int pathId;
};
class CFileSystem final : public IFileSystem
{
public:
......@@ -81,6 +88,8 @@ public:
IFile *openFile(const char *szPath, FILE_OPEN_MODE) override;
private:
void addPathInPriorityArray(int id, int iPriority);
//! Метод делает проверку, ведет ли путь к файлу или папке
bool isFileOrDirectory(const char *szPath, bool isFile);
......@@ -110,14 +119,19 @@ private:
//!корневые пути и приоритет
Array<String> m_filePaths;
Array<int> m_priority;
//!Полный путь к build
String m_pathToBuild;
Array<Pair> m_priorityArray;
//!Наш текущий ID корневого пути для записи
//! -1 - значит не установлен
int m_writableRoot = -1;
//! ID последнего элемента, который был записан
//! в корневые пути
int m_lastRootId = 0;
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment