MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / getAssetsDir

Function getAssetsDir

launcher/minecraft/AssetsUtils.cpp:173–202  ·  view source on GitHub ↗

FIXME: ugly code duplication

Source from the content-addressed store, hash-verified

171
172// FIXME: ugly code duplication
173QDir getAssetsDir(const QString& assetsId, const QString& resourcesFolder)
174{
175 QDir assetsDir = QDir("assets/");
176 QDir indexDir = QDir(FS::PathCombine(assetsDir.path(), "indexes"));
177 QDir objectDir = QDir(FS::PathCombine(assetsDir.path(), "objects"));
178 QDir virtualDir = QDir(FS::PathCombine(assetsDir.path(), "virtual"));
179
180 QString indexPath = FS::PathCombine(indexDir.path(), assetsId + ".json");
181 QFile indexFile(indexPath);
182 QDir virtualRoot(FS::PathCombine(virtualDir.path(), assetsId));
183
184 if (!indexFile.exists()) {
185 qCritical() << "No assets index file" << indexPath << "; can't determine assets path!";
186 return virtualRoot;
187 }
188
189 AssetsIndex index;
190 if (!AssetsUtils::loadAssetsIndexJson(assetsId, indexPath, index)) {
191 qCritical() << "Failed to load asset index file" << indexPath << "; can't determine assets path!";
192 return virtualRoot;
193 }
194
195 QString targetPath;
196 if (index.isVirtual) {
197 return virtualRoot;
198 } else if (index.mapToResources) {
199 return QDir(resourcesFolder);
200 }
201 return virtualRoot;
202}
203
204// FIXME: ugly code duplication
205bool reconstructAssets(QString assetsId, QString resourcesFolder)

Callers 1

processMinecraftArgsMethod · 0.85

Calls 5

PathCombineFunction · 0.85
loadAssetsIndexJsonFunction · 0.85
existsMethod · 0.80
QDirClass · 0.50
pathMethod · 0.45

Tested by

no test coverage detected