1
0
Fork 0

(svn r22905) -Fix [FS#4753] (r22836): the name of the tar was removed from the AI filenames, so record it differently. Also removes some of the hackery to get the tar's filename

release/1.2
rubidium 2011-09-08 09:55:04 +00:00
parent 414c397000
commit 62777dbd84
4 changed files with 27 additions and 15 deletions

View File

@ -423,15 +423,8 @@ static bool IsSameAI(const ContentInfo *ci, bool md5sum, AIFileInfo *info)
if (!md5sum) return true; if (!md5sum) return true;
AIFileChecksumCreator checksum; AIFileChecksumCreator checksum;
char path[MAX_PATH]; const char *tar_filename = info->GetTarFile();
strecpy(path, info->GetMainScript(), lastof(path)); TarList::iterator iter = _tar_list.find(tar_filename);
/* There'll always be at least 2 path separator characters in an AI's
* main script name as the search algorithm requires the main script to
* be in a subdirectory of the AI directory; so ai/<path>/main.nut. */
*strrchr(path, PATHSEPCHAR) = '\0';
*strrchr(path, PATHSEPCHAR) = '\0';
TarList::iterator iter = _tar_list.find(path);
if (iter != _tar_list.end()) { if (iter != _tar_list.end()) {
/* The main script is in a tar file, so find all files that /* The main script is in a tar file, so find all files that
* are in the same tar and add them to the MD5 checksumming. */ * are in the same tar and add them to the MD5 checksumming. */
@ -444,14 +437,15 @@ static bool IsSameAI(const ContentInfo *ci, bool md5sum, AIFileInfo *info)
const char *ext = strrchr(tar->first.c_str(), '.'); const char *ext = strrchr(tar->first.c_str(), '.');
if (ext == NULL || strcasecmp(ext, ".nut") != 0) continue; if (ext == NULL || strcasecmp(ext, ".nut") != 0) continue;
/* Create the full path name, */ checksum.AddFile(tar->first.c_str(), 0, tar_filename);
seprintf(path, lastof(path), "%s%c%s", tar->second.tar_filename, PATHSEPCHAR, tar->first.c_str());
checksum.AddFile(path, 0, NULL);
} }
} else { } else {
/* Add the path sep char back when searching a directory, so we are char path[MAX_PATH];
* in the actual directory. */ strecpy(path, info->GetMainScript(), lastof(path));
path[strlen(path)] = PATHSEPCHAR; /* There'll always be at least 1 path separator character in an AI's
* main script name as the search algorithm requires the main script to
* be in a subdirectory of the AI directory; so ai/<path>/main.nut. */
*strrchr(path, PATHSEPCHAR) = '\0';
checksum.Scan(".nut", path); checksum.Scan(".nut", path);
} }

View File

@ -31,6 +31,7 @@ ScriptFileInfo::~ScriptFileInfo()
free((void *)this->instance_name); free((void *)this->instance_name);
free((void *)this->url); free((void *)this->url);
free(this->main_script); free(this->main_script);
free(this->tar_file);
free(this->SQ_instance); free(this->SQ_instance);
} }
@ -69,6 +70,8 @@ bool ScriptFileInfo::CheckMethod(const char *name) const
} }
info->main_script = strdup(scanner->GetMainScript()); info->main_script = strdup(scanner->GetMainScript());
const char *tar_name = scanner->GetTarFile();
if (tar_name != NULL) info->tar_file = strdup(tar_name);
/* Cache the data the info file gives us. */ /* Cache the data the info file gives us. */
if (!info->engine->CallStringMethodStrdup(*info->SQ_instance, "GetAuthor", &info->author, MAX_GET_OPS)) return SQ_ERROR; if (!info->engine->CallStringMethodStrdup(*info->SQ_instance, "GetAuthor", &info->author, MAX_GET_OPS)) return SQ_ERROR;

View File

@ -20,6 +20,7 @@ public:
ScriptFileInfo() : ScriptFileInfo() :
SQ_instance(NULL), SQ_instance(NULL),
main_script(NULL), main_script(NULL),
tar_file(NULL),
author(NULL), author(NULL),
name(NULL), name(NULL),
short_name(NULL), short_name(NULL),
@ -76,6 +77,11 @@ public:
*/ */
const char *GetMainScript() const { return this->main_script; } const char *GetMainScript() const { return this->main_script; }
/**
* Get the filename of the tar the script is in.
*/
const char *GetTarFile() const { return this->tar_file; }
/** /**
* Check if a given method exists. * Check if a given method exists.
*/ */
@ -91,6 +97,7 @@ protected:
HSQOBJECT *SQ_instance; HSQOBJECT *SQ_instance;
private: private:
char *main_script; char *main_script;
char *tar_file;
const char *author; const char *author;
const char *name; const char *name;
const char *short_name; const char *short_name;

View File

@ -23,6 +23,14 @@ bool ScriptScanner::AddFile(const char *filename, size_t basepath_length, const
this->main_script = strdup(filename); this->main_script = strdup(filename);
if (this->main_script == NULL) return false; if (this->main_script == NULL) return false;
free(this->tar_file);
if (tar_filename != NULL) {
this->tar_file = strdup(tar_filename);
if (this->tar_file == NULL) return false;
} else {
this->tar_file = NULL;
}
const char *end = this->main_script + strlen(this->main_script) + 1; const char *end = this->main_script + strlen(this->main_script) + 1;
char *p = strrchr(this->main_script, PATHSEPCHAR); char *p = strrchr(this->main_script, PATHSEPCHAR);
if (p == NULL) { if (p == NULL) {