예제 #1
0
APIModVersion::APIModVersion(CharString versionstr){ // discards name split from ':', only keeps version number
    major = minor = submajor = subminor = 0;
    atleastver = false;
    
    // forget modname if it is still in the string
    if(versionstr.contains(":")){
        LinkedList<CharString> vsplit = versionstr.split(":");
        versionstr = vsplit[1];
    }
    
    this->versionstring = versionstr; // keep original string
    
    if(versionstr.startsWith(">")){
        atleastver = true;
        versionstr.shiftLeft(1);
    }
    
    if(versionstr.startsWith("v")) versionstr.shiftLeft(1);
    
    if(versionstr.contains(".")){
        LinkedList<CharString> vsplit = versionstr.split(".");
        if(vsplit[0].isValidNumber()) major = vsplit[0].getInt();
        if(vsplit[1].isValidNumber()) minor = vsplit[1].getInt();
        if(vsplit.size() >= 3 && vsplit[2].isValidNumber()) submajor = vsplit[2].getInt();
        if(vsplit.size() >= 4 && vsplit[3].isValidNumber()) subminor = vsplit[3].getInt();
    }else{
        // what? Single version number?
        if(versionstr.isValidNumber()){
            major = versionstr.getInt();
        }else{
            // dunno...
            cout << "API Mod Version could not figure out the version for " << versionstring << endl;
        }
    }
}
예제 #2
0
// return a list of dependencies with name:version string for missing/different version mods.
LinkedList<CharString> APIMod::getMissingDependencies(LinkedList<APIMod*> othermods){
    LinkedList<CharString> strs;
    LinkedListIterator<CharString> depstrs = dependencyversions.getIterator();
    
    while(depstrs.hasNext()){
        CharString depstr = depstrs.next();
        if(depstr.contains(":")){
            LinkedListIterator<APIMod*> modit = othermods.getIterator();
            bool identified = false;
            while(modit.hasNext()){
                APIMod *mod = modit.next();
                // compare direct
                if(unixname.compare(mod->unixname) && version.compareVersion(mod->versionstr)){
                    // not the same or and older version
                    identified = true; // same
                    break;
                }
            }
            
            if(!identified){
                strs.add(depstr); // "mod:version"
            }
            
        } // else invalid!
    }
    
    return strs;
}
예제 #3
0
/* Adds a file to the current directory based on location.
 */
void FileSystem::addFile(CharString location) {
    // get base path
    FileStructureNode* node = getBaseNodeFromString(location);
    // get name from last "/"
    CharString name = getNameFromString(location);

    // make sure that the node is viable. (base path is current dir)
    if(node == 0x0 && !location.contains("/")) node = Current;

    // init a new node
    FileStructureNode* nodenew = new FileStructureNode();
    nodenew->Parent = node;
    nodenew->name = name;
    nodenew->type = File;

    // add node to the filesystem
    node->addObject(nodenew);
}
예제 #4
0
// figure out what mods have good dependencies
bool APIMod::compareModDependencies(LinkedList<APIMod*> othermods){
    LinkedListIterator<CharString> depstrs = dependencyversions.getIterator();
    
    while(depstrs.hasNext()){
        CharString depstr = depstrs.next();
        if(depstr.contains(":")){
            LinkedListIterator<APIMod*> modit = othermods.getIterator();
            while(modit.hasNext()){
                APIMod *mod = modit.next();
                // compare direct
                if(! version.compareVersion(mod->version)){
                    // not the same or and older version
                    return false;
                }
            }
            
        } // else invalid!
    }
}
예제 #5
0
/* Returns the name of the end point.
*  Input: String location
*  Output: Very ending of string after last "/"
 */
CharString FileSystem::getNameFromString(CharString location) {
    // gets the name of the last "/dir/dir2/name", even if it ends with "/".
    if(location.get()[location.getSize()-1] == '/') {
        // remove trailing "/".
        location.get()[location.getSize()-1] = '\0';
        location.setSize(location.getSize()-1);
    }

    CharString result = CharString("");
    // split all by "/".
    if(location.contains("/")) {
        // get the very last result of the split.
        LinkedList<CharString>* sresult = location.split('/','`');
        result = *sresult->get(sresult->size()-1);
    } else {
        result = location;
    }

    return result;
}
예제 #6
0
// LinkedList<LinkedList<CharString>> lines = SimpleParseFile(file, '\n');
void APIMod::loadProperties(){ // , CharString name, CharString language, CharString version
    if(propertiesloaded) return;

    LinkedList<LinkedList<CharString>> lines = SimpleParseString(getModFileData("mod.properties"), '=');

    CharString depvers = "";
    LinkedListIterator<LinkedList<CharString>> lineit = lines.getIterator();
    while(lineit.hasNext()){
        LinkedList<CharString> p = lineit.next();
        CharString pname = p[0];
        if(pname.compare(CharString("name")))
            this->name = p[1];
        else if(pname.compare(CharString("unixname")))
            this->unixname = p[1];
        else if(pname.compare(CharString("language"))) // c++, java, etc.
            this->language = p[1];
        else if(pname.compare(CharString("version"))){
            this->versionstr = p[1];
            this->version = APIModVersion(p[1]);
        }else if(pname.compare(CharString("dependency_versions")))
            depvers = p[1];
    }

    this->modcwdloc = unixname; // relative folder location for mod
    
    // load dependency versioning information
    //      this->dependencyversions.add("mod1:v12938");
    if(depvers.getSize() > 3){
        if(depvers.contains(", ")){
            depvers.replace(" ", "");
            LinkedList<CharString> v = depvers.split(",");
            this->dependencyversions.addAll(v);
        }else{
            this->dependencyversions.add(depvers);
        }
    }


    propertiesloaded=true;
}