void QQMlDom::mkDefaultDirs(const QString rootDir,const QString projectName,const QString appName)
{
    QString configDir = QString("%1/%2").arg(rootDir).arg("config");
    QString pDir  = QString ("%1/%2/%3").arg(rootDir).arg(projectName).arg("meta");
    QString online = QString("%1/%2").arg(rootDir).arg("package_update");
    QString resource = QString("%1/%2").arg(rootDir).arg("resource");

    //    qDebug() << configDir;
    //    qDebug() << pDir;
    //    qDebug() << rootDir;

    QDir dir(rootDir);

    if ( !dir.exists() )
    {
        if( !dir.mkpath(rootDir) )
        {
            error("could not make root dir");
        }

        if( !dir.mkpath(configDir) )
        {
            error("could not make the confiure dir");
        }

        if( !dir.mkpath(pDir) )
        {
            error("could not make package dir");
        }

        if( !dir.mkpath(online))
        {
            error("could not make online dir");
        }

        if( !dir.mkpath(resource))
        {
            error("could not make online dir");
        }

        //  make the files
        // FIXME make these bool and not void
        makeProFile(rootDir,appName);
        makeConfigFile(configDir,"config.xml");
        makePackageFile(pDir,"package.xml");
        makeQSFile(pDir,"installscript.qs");
        makeLicenseFile(pDir,"license.txt");
        makeREADMEFile(rootDir,"README");

        //        now  write to the confi.xml and also the package.xml
        writeConfigPage(configDir);
        writePackagePage(pDir);
    } else {
        error("Root Dir is already there Mybe you want to alter it ?");
    }
}
Пример #2
0
void Guys::configurationFileCheck() {
	if( configFileExists("guys/twitter") ) {
		//std::cout << "file exists" << std::endl;
		
		FILE *pFile;
		char buffer [100];
		std::string result;
		std::string command = "cd ~/ && pwd";
		std::string file;

		pFile = popen(command.c_str(), "r");
		
		if (pFile == NULL) {
			std::cout << "handle error" << std::endl;
			return;
		} else {
			while ( !feof(pFile) ) {
				fgets (buffer , 100 , pFile);
			}
			pclose (pFile);
		}
		result = buffer;
		configPath = result + "/.config/guys/"; //accessible to all functions
		
		std::string::iterator it;
		for ( it=configPath.begin() ; it < configPath.end(); it++ )
			if (*it == 10) configPath.erase(it); //erase return characters
		
	} else {
		if( folderExists("~/.config/guys") ) {
			std::cout << "creating config files in ~/.config/guys/" << std::endl; //but not the file
			makeConfigFile("guys/twitter"); //create the file
			configurationFileCheck();
		} else {
			makeConfigDir("guys");
			configurationFileCheck();
		}
	}
	
	return;
}