MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / getAssetsDir

Function getAssetsDir

launcher/minecraft/AssetsUtils.cpp:187–221  ·  view source on GitHub ↗

FIXME: ugly code duplication

Source from the content-addressed store, hash-verified

185
186// FIXME: ugly code duplication
187QDir getAssetsDir(const QString &assetsId, const QString &resourcesFolder)
188{
189 QDir assetsDir = QDir("assets/");
190 QDir indexDir = QDir(FS::PathCombine(assetsDir.path(), "indexes"));
191 QDir objectDir = QDir(FS::PathCombine(assetsDir.path(), "objects"));
192 QDir virtualDir = QDir(FS::PathCombine(assetsDir.path(), "virtual"));
193
194 QString indexPath = FS::PathCombine(indexDir.path(), assetsId + ".json");
195 QFile indexFile(indexPath);
196 QDir virtualRoot(FS::PathCombine(virtualDir.path(), assetsId));
197
198 if (!indexFile.exists())
199 {
200 qCritical() << "No assets index file" << indexPath << "; can't determine assets path!";
201 return virtualRoot;
202 }
203
204 AssetsIndex index;
205 if(!AssetsUtils::loadAssetsIndexJson(assetsId, indexPath, index))
206 {
207 qCritical() << "Failed to load asset index file" << indexPath << "; can't determine assets path!";
208 return virtualRoot;
209 }
210
211 QString targetPath;
212 if(index.isVirtual)
213 {
214 return virtualRoot;
215 }
216 else if(index.mapToResources)
217 {
218 return QDir(resourcesFolder);
219 }
220 return virtualRoot;
221}
222
223// FIXME: ugly code duplication
224bool reconstructAssets(QString assetsId, QString resourcesFolder)

Callers 1

processMinecraftArgsMethod · 0.85

Calls 5

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

Tested by

no test coverage detected