GetArchivePath.diff (2,394 bytes)
2007-09-14 11:43
Index: rts/System/FileSystem/ArchiveScanner.cpp
===================================================================
--- rts/System/FileSystem/ArchiveScanner.cpp (revision 4371)
+++ rts/System/FileSystem/ArchiveScanner.cpp (working copy)
@@ -536,6 +536,27 @@
return aii->second.checksum;
}
+std::string CArchiveScanner::GetArchivePath(const string& name)
+{
+ string lcname = name;
+
+ // Strip path-info if present
+ if (lcname.find_last_of('\\') != string::npos)
+ lcname = lcname.substr(lcname.find_last_of('\\') + 1);
+ if (lcname.find_last_of('/') != string::npos)
+ lcname = lcname.substr(lcname.find_last_of('/') + 1);
+
+ StringToLowerInPlace(lcname);
+
+ map<string, ArchiveInfo>::iterator aii = archiveInfo.find(lcname);
+ if (aii == archiveInfo.end()) {
+ logOutput.Print("GetArchivePath: Could not find archive \"%s\"", name.c_str());
+ return 0;
+ }
+
+ return aii->second.path;
+}
+
/** Get checksum of all required archives depending on selected mod. */
unsigned int CArchiveScanner::GetModChecksum(const string& root)
{
Index: rts/System/FileSystem/ArchiveScanner.h
===================================================================
--- rts/System/FileSystem/ArchiveScanner.h (revision 4371)
+++ rts/System/FileSystem/ArchiveScanner.h (working copy)
@@ -49,6 +49,7 @@
vector<string> GetMaps();
vector<string> GetArchivesForMap(const string& mapName);
unsigned int GetArchiveChecksum(const string& name);
+ std::string GetArchivePath(const string& name);
unsigned int GetModChecksum(const string& root);
unsigned int GetMapChecksum(const string& mapName);
void CheckMod(const string& root, unsigned checksum); // these throw a content_error if checksum doesn't match
Index: tools/unitsync/unitsync.cpp
===================================================================
--- tools/unitsync/unitsync.cpp (revision 4371)
+++ tools/unitsync/unitsync.cpp (working copy)
@@ -280,6 +280,13 @@
return archiveScanner->GetArchiveChecksum(arname);
}
+DLL_EXPORT const char* __stdcall GetArchivePath(const char* arname)
+{
+ ASSERT(archiveScanner && hpiHandler, "Call InitArchiveScanner before GetArchivePath.");
+ ASSERT(arname && *arname, "Don't pass a NULL pointer or an empty string to GetArchivePath.");
+ return archiveScanner->GetArchivePath(arname).c_str();
+}
+
// Updated on every call to getmapcount
static vector<string> mapNames;