!XT (BREAK-16) (Sandbox) Remove double-newlines at the end of files.
[CRYENGINE.git] / Code / Sandbox / Plugins / EditorCommon / FileSystem / Internal / FileSystem_Internal_PakFiles.cpp
blobe5001b0accba420a650e55edf9c055fd703a54f6
1 // Copyright 2001-2018 Crytek GmbH / Crytek Group. All rights reserved.
2 #include "StdAfx.h"
3 #include "FileSystem_Internal_PakFiles.h"
5 #include <CrySystem/File/ICryPak.h>
6 #include <IEditor.h>
8 namespace FileSystem
10 namespace Internal
13 SArchiveContentInternal CPakFiles::GetContents(const QString& keyEnginePath) const
15 SArchiveContentInternal result;
16 //result.pakFilePath = enginePath;
17 #ifndef EDITOR_COMMON_EXPORTS
18 Q_UNUSED(keyEnginePath); // its always the same fake
19 SDirectoryInfoInternal fakeFolder;
20 fakeFolder.SetAbsolutePath(SAbsolutePath("Fakefolder"));
21 result.directories << fakeFolder;
23 SDirectoryInfoInternal subFolder;
24 subFolder.SetAbsolutePath(SAbsolutePath("Fakefolder/Subfolder"));
25 result.directories << subFolder;
27 QDateTime fakeTime(QDate(2016, 1, 1), QTime(12, 11, 10, 9));
29 SFileInfoInternal fileInfo1;
30 fileInfo1.SetAbsolutePath(SAbsolutePath("Fakefolder/Fakefile.txt"));
31 fileInfo1.size = 42;
32 fileInfo1.lastModified = fakeTime;
33 result.files << fileInfo1;
35 SFileInfoInternal fileInfo2;
36 fileInfo2.SetAbsolutePath(SAbsolutePath("Fakefolder/Morefile.png"));
37 fileInfo2.size = 2048;
38 fileInfo2.lastModified = fakeTime;
39 result.files << fileInfo2;
40 #else
41 // real implementation
42 auto keyEnginePathStr = keyEnginePath.mid(1).toStdString();
43 QStringList directoryList;
44 GetContentsInternal(keyEnginePathStr, QString(), result, directoryList);
45 for (int i = 0; i < directoryList.size(); ++i)
47 GetContentsInternal(keyEnginePathStr, directoryList[i] + '/', result, directoryList);
49 #endif
50 return result;
53 #ifdef EDITOR_COMMON_EXPORTS
55 void CPakFiles::GetContentsInternal(const std::string& archiveEnginePathStr, const QString& fullLocalPath, SArchiveContentInternal& result, QStringList& directoryList) const
57 static QDateTime fileTimeOrigin(QDate(1601, 1, 1), QTime(0, 0, 0, 0), Qt::UTC);
59 std::string levelPakPath(GetIEditor()->GetLevelName());
60 levelPakPath += "/level.pak";
62 if (archiveEnginePathStr.find(levelPakPath) != std::string::npos) // don't index the level.pak
63 return;
65 auto pIPak = GetIEditor()->GetSystem()->GetIPak();
66 assert(pIPak);
67 auto searchStr = (fullLocalPath + "*").toStdString();
68 pIPak->ForEachArchiveFolderEntry(
69 archiveEnginePathStr.c_str(),
70 searchStr.c_str(),
71 [&](const ICryPak::ArchiveEntryInfo& entry)
73 auto entryFullName = QString::fromLocal8Bit(entry.szName);
74 auto entryFullLocalPath = (fullLocalPath + entryFullName);
75 if (entry.bIsFolder)
77 SDirectoryInfoInternal directoryInfo;
78 directoryInfo.absolutePath = SAbsolutePath(entryFullLocalPath);
79 directoryInfo.fullName = entryFullName;
80 directoryInfo.keyName = entryFullName.toLower();
81 result.directories << directoryInfo;
82 directoryList << entryFullLocalPath;
84 else
86 auto lastModified = fileTimeOrigin.addMSecs(entry.aModifiedTime / 10000); // 100 nanoseconds
87 SFileInfoInternal fileInfo;
88 fileInfo.absolutePath = SAbsolutePath(entryFullLocalPath);
89 fileInfo.fullName = entryFullName;
90 fileInfo.keyName = entryFullName.toLower();
91 fileInfo.extension = GetFileExtensionFromFilename(fileInfo.keyName);
92 fileInfo.size = entry.size;
93 fileInfo.lastModified = lastModified;
94 result.files << fileInfo;
96 });
98 #endif
100 } // namespace Internal
101 } // namespace FileSystem