|
@@ -9,29 +9,27 @@
|
|
|
|
|
|
/** @file script_scanner.cpp Allows scanning for scripts. */
|
|
|
|
|
|
#include "../stdafx.h"
|
|
|
#include "../debug.h"
|
|
|
#include "../string_func.h"
|
|
|
#include "../settings_type.h"
|
|
|
|
|
|
#include "../script/squirrel.hpp"
|
|
|
#include "script_scanner.hpp"
|
|
|
#include "script_info.hpp"
|
|
|
|
|
|
#if defined(ENABLE_NETWORK)
|
|
|
#include "../network/network_content.h"
|
|
|
#include "../3rdparty/md5/md5.h"
|
|
|
#include "../tar_type.h"
|
|
|
#endif /* ENABLE_NETWORK */
|
|
|
|
|
|
#include "../safeguards.h"
|
|
|
|
|
|
bool ScriptScanner::AddFile(const char *filename, size_t basepath_length, const char *tar_filename)
|
|
|
{
|
|
|
free(this->main_script);
|
|
|
this->main_script = stredup(filename);
|
|
|
if (this->main_script == NULL) return false;
|
|
|
|
|
|
free(this->tar_file);
|
|
|
if (tar_filename != NULL) {
|
|
|
this->tar_file = stredup(tar_filename);
|
|
@@ -171,26 +169,24 @@ char *ScriptScanner::GetConsoleList(char
|
|
|
p += seprintf(p, last, "List of %s:\n", this->GetScannerName());
|
|
|
const ScriptInfoList &list = newest_only ? this->info_single_list : this->info_list;
|
|
|
ScriptInfoList::const_iterator it = list.begin();
|
|
|
for (; it != list.end(); it++) {
|
|
|
ScriptInfo *i = (*it).second;
|
|
|
p += seprintf(p, last, "%10s (v%d): %s\n", i->GetName(), i->GetVersion(), i->GetDescription());
|
|
|
}
|
|
|
p += seprintf(p, last, "\n");
|
|
|
|
|
|
return p;
|
|
|
}
|
|
|
|
|
|
#if defined(ENABLE_NETWORK)
|
|
|
|
|
|
/** Helper for creating a MD5sum of all files within of a script. */
|
|
|
struct ScriptFileChecksumCreator : FileScanner {
|
|
|
byte md5sum[16]; ///< The final md5sum.
|
|
|
Subdirectory dir; ///< The directory to look in.
|
|
|
|
|
|
/**
|
|
|
* Initialise the md5sum to be all zeroes,
|
|
|
* so we can easily xor the data.
|
|
|
*/
|
|
|
ScriptFileChecksumCreator(Subdirectory dir)
|
|
|
{
|
|
|
this->dir = dir;
|
|
@@ -278,14 +274,12 @@ bool ScriptScanner::HasScript(const Cont
|
|
|
if (IsSameScript(ci, md5sum, (*it).second, this->GetDirectory())) return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
const char *ScriptScanner::FindMainScript(const ContentInfo *ci, bool md5sum)
|
|
|
{
|
|
|
for (ScriptInfoList::iterator it = this->info_list.begin(); it != this->info_list.end(); it++) {
|
|
|
if (IsSameScript(ci, md5sum, (*it).second, this->GetDirectory())) return (*it).second->GetMainScript();
|
|
|
}
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
#endif /* ENABLE_NETWORK */
|