Esempio n. 1
0
void EasySFML::update(){
    cout << "download: " << "http://magrassteve.atspace.eu/EasySFML/compiler.xml" << "..." << endl;
    get_http_data("http://magrassteve.atspace.eu/EasySFML/compiler.xml","conf/compiler.xml");
    cout << "download: " << "http://magrassteve.atspace.eu/EasySFML/cmake.xml" << "..." << endl;
    get_http_data("http://magrassteve.atspace.eu/EasySFML/cmake.xml","conf/cmake.xml");
    cout << "download: " << "http://magrassteve.atspace.eu/EasySFML/version.xml" << "..." << endl;
    get_http_data("http://magrassteve.atspace.eu/EasySFML/version.xml","conf/version.xml");
    cout << "download: " << "http://magrassteve.atspace.eu/EasySFML/help.txt" << "..." << endl;
    get_http_data("http://magrassteve.atspace.eu/EasySFML/help.txt","conf/help.txt");
}
Esempio n. 2
0
int main() 
{
//http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf
  std::string result = get_http_data("www.open-std.org", "/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf");

  std::ofstream of("cpp11_draft_n3242.pdf", std::ios::binary);
  of << result;
}
Esempio n. 3
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);
        }


}
Esempio n. 4
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);
                }



            }
        }

    }



}