1 // Copyright 2001-2018 Crytek GmbH / Crytek Group. All rights reserved.
3 #include "FileSystem_Internal_PakFiles.h"
5 #include <CrySystem/File/ICryPak.h>
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"));
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
;
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
);
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
65 auto pIPak
= GetIEditor()->GetSystem()->GetIPak();
67 auto searchStr
= (fullLocalPath
+ "*").toStdString();
68 pIPak
->ForEachArchiveFolderEntry(
69 archiveEnginePathStr
.c_str(),
71 [&](const ICryPak::ArchiveEntryInfo
& entry
)
73 auto entryFullName
= QString::fromLocal8Bit(entry
.szName
);
74 auto entryFullLocalPath
= (fullLocalPath
+ entryFullName
);
77 SDirectoryInfoInternal directoryInfo
;
78 directoryInfo
.absolutePath
= SAbsolutePath(entryFullLocalPath
);
79 directoryInfo
.fullName
= entryFullName
;
80 directoryInfo
.keyName
= entryFullName
.toLower();
81 result
.directories
<< directoryInfo
;
82 directoryList
<< entryFullLocalPath
;
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
;
100 } // namespace Internal
101 } // namespace FileSystem