Exemplo n.º 1
0
TIFILE_t* ImportZipFile(LPCTSTR filePath, TIFILE_t *tifile) {
	unzFile uf;
	TCHAR path[MAX_PATH];
	uf = unzOpen(filePath);
	StringCbCopy(path, sizeof(path), _tgetenv(_T("appdata")));
	StringCbCat(path, sizeof(path), _T("\\Wabbitemu"));
	int err = extract_zip(uf, path);
	unzClose(uf);
	return err ? NULL: tifile;
}
Exemplo n.º 2
0
/** Installs or updates (i.e. = install on top of an existing installation) an 
 *  addon. It checks for the directories and then unzips the file (which must 
 *  already have been downloaded).
 *  \param addon Addon data for the addon to install.
 *  \return true if installation was successful.
 */
bool AddonsManager::install(const Addon &addon)
{
    bool success=true;
    const std::string &id = addon.getId();
    file_manager->checkAndCreateDirForAddons(id, addon.getTypeDirectory());

    //extract the zip in the addons folder called like the addons name    
    std::string base_name = StringUtils::getBasename(addon.getZipFileName());
    std::string from      = file_manager->getAddonsFile("tmp/"+base_name);
    std::string to        = addon.getDataDir();
    
    success = extract_zip(from, to);
    if (!success)
    {
        // TODO: show a message in the interface
        std::cerr << "[addons] Failed to unzip '" << from << "' to '" 
                  << to << "'\n";
        std::cerr << "[addons] Zip file will not be removed.\n";
        return false;
    }

    if(!file_manager->removeFile(from))
    {
        std::cerr << "[addons] Problems removing temporary file '"
                  << from << "'.\n";
    }

    int index = getAddonIndex(addon.getId());
    assert(index>=0 && index < (int)m_addons_list.getData().size());
    m_addons_list.getData()[index].setInstalled(true);
    
    if(addon.getType()=="kart")
    {
        // We have to remove the mesh of the kart since otherwise it remains
        // cashed (if a kart is updated), and will therefore be found again 
        // when reloading the karts. This is important on one hand since we 
        // reload all karts (this function is easily available) and existing
        // karts will not reload their meshes.
        const KartProperties *prop = 
            kart_properties_manager->getKart(addon.getId());
        // If the model already exist, first remove the old kart
        if(prop)
            kart_properties_manager->removeKart(addon.getId());
        kart_properties_manager->loadKart(addon.getDataDir());
    }
    else if (addon.getType()=="track" || addon.getType()=="arena")
    {
        Track *track = track_manager->getTrack(addon.getId());
        if(track)
            track_manager->removeTrack(addon.getId());
        track_manager->loadTrack(addon.getDataDir());
    }
    saveInstalled();
    return true;
}   // install
Exemplo n.º 3
0
void download_main_is_finished(void *data, const char *file, int status){
	is_downloading = false;
	is_running = false;
	if(status != 200){
		override_text(&info, "information_download", "No internet connection");
		download_is_failed = true;
		ecore_main_loop_iterate();
		sleep(2);
		return ;
	}
	override_text(&info, "information_download", "Extracting..");
	ecore_main_loop_iterate();
	sleep(1);
	extract_zip(file,CACHE_PATH);
	file_delete(file);
	override_text(&info, "information_download", "Loading menu..");
	ecore_main_loop_iterate();
}
Exemplo n.º 4
0
void EasySFML::config(){

        string typeCompiler;
        string compiler;
        string cmake;
        bool ok = true;

        // Type de compiler
        SetColor(DARKGREEN);

        cout << "# Enter the number in the list to define your compiler." << endl;
        cout << "# ex: 1" << endl;

        XMLNode xMainNode=XMLNode::openFileHelper("conf/compiler.xml","PMML");
        XMLNode xcompilers=xMainNode.getChildNode("compilers");
        int n=xcompilers.nChildNode("compiler");
        for (int i = 0; i < n;i++ ){
        XMLNode xcompiler =xcompilers.getChildNode("compiler",i);
        cout << i << " : " << xcompiler.getChildNode("name").getText() << endl;
        }

        SetColor(WHITE);
        cout << "Compiler >> " ;
        getline(cin, compiler);
        cout << endl;

        int i = atoi(compiler.c_str());
        if (!(i >= 0 && i < n) || compiler == ""){
            ok = false;
            SetColor(RED);
            cout << "ERROR: Impossible to choose compiler '" << compiler << "' ."<< endl << endl;
            SetColor(WHITE);
        }
        else{
            _compilertype = compiler;
        }

        // Compiler
        if(ok){
            XMLNode xcompiler =xcompilers.getChildNode("compiler",i);

            SetColor(DARKGREEN);
            cout << "# Enter your compiler path:" << endl;
            cout << "# ex: " << xcompiler.getChildNode("example").getText() << endl;
            SetColor(WHITE);
            cout << "Compiler path >> " ;
            getline(cin, compiler);
            cout << endl;



            string compExe = compiler+xcompiler.getChildNode("bin").getText();
            if (!fileExist(compExe)){
                ok = false;
                SetColor(RED);
                cout << "ERROR: Impossible to find '"<< compExe <<"' ." << endl << endl;
                SetColor(WHITE);
            }else{

                _compilerpath = compiler;
            }
        }

        _compilerpath = clean_path(_compilerpath);

        // Cmake
        if(ok){
            SetColor(DARKGREEN);
            cout << "# Enter your cmake path or ENTER for automatic download:" << endl;
            cout << "# ex: C:\\Cmake" << endl;
            SetColor(WHITE);
            cout << "Cmake path >> " ;
            getline(cin, cmake);
            cout << endl;

            if (cmake == ""){

                XMLNode confxml = XMLNode::openFileHelper("conf/cmake.xml","PMML");
                XMLNode xcmake = confxml.getChildNode("cmake");

                if (!fileExist(xcmake.getChildNode("zip").getText())){
                    cout << "Download: "<< xcmake.getChildNode("url").getText() << "..." << endl;
                    get_http_data(xcmake.getChildNode("url").getText(),xcmake.getChildNode("zip").getText());
                }

                if (!fileExist(xcmake.getChildNode("src").getText())){
                    cout << "Unzip: "<< xcmake.getChildNode("zip").getText() << "..." << endl;
                    extract_zip("download/cmake",xcmake.getChildNode("zip").getText());
                    cmake = xcmake.getChildNode("path").getText();
                }


                cmake = xcmake.getChildNode("path").getText();
                cmake = GetPath()+"\\"+cmake+"\\";
// C:/Users/STEVE/Desktop/Projet/C++/download/cmake/cmake-2.8.12.2-win32-x86/bin/cmake.exe

            }

            cmake = clean_path(cmake);

            string cmakeExe = cmake+"bin/cmake.exe";
            if (!fileExist(cmakeExe)){
                ok = false;
                SetColor(RED);
                cout << "ERROR: Impossible to find '"<< cmakeExe <<"' ." << endl << endl;
                SetColor(WHITE);
            }
            else{
                _cmakepath = cmake;

            }
        }

        // End
        if (ok){
            SetColor(DARKGREEN);
            save();
            cout << "Configuration is succesfully done." << endl;
            SetColor(WHITE);
        }


}
Exemplo n.º 5
0
void EasySFML::install(){

    if (checkConfig()){

        SetColor(DARKGREEN);

        string version;
        bool ok=true;
        string finalpath;
        string command = "";

        // Final Path
        if(ok){

            SetColor(DARKGREEN);
            cout << "# Enter where you want to install sfml:" << endl;
            cout << "# ex: C:/" << endl;
            SetColor(WHITE);
            cout << "SFML path >> " ;
            getline(cin, finalpath);
            cout << endl;

            if (finalpath != ""){
                finalpath = clean_path(finalpath);
                if (!dirExist(finalpath)){
                    SetColor(RED);
                    cout << "ERROR: Impossible to find folder '" << finalpath << "' ."<< endl << endl;
                    SetColor(WHITE);
                    ok = false;
                }
            }
            else{
                SetColor(RED);
                cout << "ERROR: Impossible to find folder '" << finalpath << "' ."<< endl << endl;
                SetColor(WHITE);
                ok = false;
            }
        }

        if (ok){
            SetColor(DARKGREEN);
            cout << "# Enter the sfml version to install." << endl;
            cout << "# ex: 1" << endl;

            XMLNode xMainNode=XMLNode::openFileHelper("conf/version.xml","PMML");
            XMLNode xversions=xMainNode.getChildNode("versions");
            int n=xversions.nChildNode("version");
            for (int i = 0; i < n;i++ ){
                XMLNode xversion =xversions.getChildNode("version",i);
                cout << i << " : " << xversion.getChildNode("name").getText() << endl;
            }

            SetColor(WHITE);
            cout << "Version >> " ;
            getline(cin, version);
            cout << endl;

            int i = atoi(version.c_str());
            if (!(i >= 0 && i < n) || version == ""){
                ok = false;
                SetColor(RED);
                cout << "ERROR: Impossible to choose version '" << version << "' ."<< endl << endl;
                SetColor(WHITE);
            }
            else{
               // _compilertype = version;
               int i = atoi(version.c_str());
                XMLNode xversion =xversions.getChildNode("version",i);
                string sfmlPath = xversion.getChildNode("path").getText();
                if (!dirExist(sfmlPath)){
                    cout << "Create new dir: '"<< sfmlPath <<"'" << endl;
                    if (!dirExist("download/versions/")) mkdir("download/versions/");
                    mkdir(sfmlPath.c_str());

                }

                if (!fileExist(xversion.getChildNode("zip").getText())){
                    cout << "Download: "<< xversion.getChildNode("url").getText() << "..." << endl;
                    get_http_data(xversion.getChildNode("url").getText(),xversion.getChildNode("zip").getText());
                }



                cout << "Delete: "<< xversion.getChildNode("src").getText() << "..." << endl;
                command = xversion.getChildNode("src").getText();
                command = "rd /s /q \""+command+"\"";
                system( command.c_str() );
                cout << "Unzip: "<< xversion.getChildNode("zip").getText() << "..." << endl;
                extract_zip(xversion.getChildNode("path").getText(),xversion.getChildNode("zip").getText());

                // Compilation
                string mainpath = GetPath();
                string compiler = getCompiler();
                string src_sfml = xversion.getChildNode("src").getText();

                command = "";
                command += "cd " + src_sfml + " && ";
                command += "set PATH=\""+_compilerpath +"bin/\";%PATH%" + " && ";
                command += "set PATH=\""+_cmakepath +"bin/\";%PATH%" + " && ";
                command += "cmake -G \""+compiler+"\" -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=TRUE \"" + mainpath+"/"+src_sfml + "\" && ";
                command += "mingw32-make &&";
                command += "cmake -G \""+compiler+"\" -D CMAKE_BUILD_TYPE=Debug -D BUILD_SHARED_LIBS=TRUE \"" + mainpath+"/"+src_sfml + "\" && ";
                command += "mingw32-make && ";
                command += "cmake -G \""+compiler+"\" -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=FALSE \"" + mainpath+"/"+src_sfml + "\" && ";
                command += "mingw32-make && ";
                command += "cmake -G \""+compiler+"\" -D CMAKE_BUILD_TYPE=Debug -D BUILD_SHARED_LIBS=FALSE \"" + mainpath+"/"+src_sfml + "\" && ";
                command += "mingw32-make";
                //cout << command << endl;
                int resCMD = system(command.c_str());

                if (resCMD == 0 && errno == 0)
                {
                    cout << "Finalize installation..." << endl;
                    command = xversion.getChildNode("name").getText();
                    command = "xcopy  \""+ mainpath+"/"+src_sfml +"\" \""+finalpath+"/"+command+"\" /s /e /y /i";
                    cout << command << endl;
                    system(command.c_str());

                    cout << endl << "Installation complete." << endl;
                }
                else{
                    SetColor(RED);
                    cout << "ERROR: Impossible to cmake or compile." << endl;
                    SetColor(WHITE);
                }



            }
        }

    }



}