int main (int argc,char *argv[]){ // all args are meant to be brought if (argc!=1) { char file_name[4096]; char file_addr[4096]; char wrk_dir[4096]; int i; // get file path if (getWorkingDir(&wrk_dir)==0) { if (DEBUG) printf ("[debug] wrk_dir = %s\n",wrk_dir); } if (DEBUG) printf("[debug] sizeof(argc)=%d\n",sizeof(argc)); for (i = 1; i < argc; i++) { strcpy(file_name,argv[i]); if (DEBUG) printf("[debug] file_name = %s\n",file_name); fileExist(file_name); sprintf(file_addr,strcat(strcat(wrk_dir,"/"),file_name)); if (DEBUG) printf("[debug] file_addr=%s\n",file_addr); // add a comma if more than 1 exists if (argc-i!=0) storePath(strcat(file_addr,",")); else storePath(file_addr); } return 0; } else { // if none, drop // check for file waiting to be dropped if (bring_it()!=0){ printf("No file to be brought.\n"); } } if (DEBUG) printf("[debug] returning\n"); return 0; }
void LLDir::dumpCurrentDirectories() { LL_DEBUGS2("AppInit","Directories") << "Current Directories:" << LL_ENDL; LL_DEBUGS2("AppInit","Directories") << " CurPath: " << getCurPath() << LL_ENDL; LL_DEBUGS2("AppInit","Directories") << " AppName: " << getAppName() << LL_ENDL; LL_DEBUGS2("AppInit","Directories") << " ExecutableFilename: " << getExecutableFilename() << LL_ENDL; LL_DEBUGS2("AppInit","Directories") << " ExecutableDir: " << getExecutableDir() << LL_ENDL; LL_DEBUGS2("AppInit","Directories") << " ExecutablePathAndName: " << getExecutablePathAndName() << LL_ENDL; LL_DEBUGS2("AppInit","Directories") << " WorkingDir: " << getWorkingDir() << LL_ENDL; LL_DEBUGS2("AppInit","Directories") << " AppRODataDir: " << getAppRODataDir() << LL_ENDL; LL_DEBUGS2("AppInit","Directories") << " OSUserDir: " << getOSUserDir() << LL_ENDL; LL_DEBUGS2("AppInit","Directories") << " OSUserAppDir: " << getOSUserAppDir() << LL_ENDL; LL_DEBUGS2("AppInit","Directories") << " LindenUserDir: " << getLindenUserDir() << LL_ENDL; LL_DEBUGS2("AppInit","Directories") << " TempDir: " << getTempDir() << LL_ENDL; LL_DEBUGS2("AppInit","Directories") << " CAFile: " << getCAFile() << LL_ENDL; LL_DEBUGS2("AppInit","Directories") << " SkinBaseDir: " << getSkinBaseDir() << LL_ENDL; LL_DEBUGS2("AppInit","Directories") << " SkinDir: " << getSkinDir() << LL_ENDL; }
void LLDir::dumpCurrentDirectories() { LL_DEBUGS2("AppInit","Directories") << "Current Directories:" << LL_ENDL; LL_DEBUGS2("AppInit","Directories") << " CurPath: " << getCurPath() << LL_ENDL; LL_DEBUGS2("AppInit","Directories") << " AppName: " << getAppName() << LL_ENDL; LL_DEBUGS2("AppInit","Directories") << " ExecutableFilename: " << getExecutableFilename() << LL_ENDL; LL_DEBUGS2("AppInit","Directories") << " ExecutableDir: " << getExecutableDir() << LL_ENDL; LL_DEBUGS2("AppInit","Directories") << " ExecutablePathAndName: " << getExecutablePathAndName() << LL_ENDL; LL_DEBUGS2("AppInit","Directories") << " WorkingDir: " << getWorkingDir() << LL_ENDL; LL_DEBUGS2("AppInit","Directories") << " AppRODataDir: " << getAppRODataDir() << LL_ENDL; LL_DEBUGS2("AppInit","Directories") << " OSUserDir: " << getOSUserDir() << LL_ENDL; LL_DEBUGS2("AppInit","Directories") << " OSUserAppDir: " << getOSUserAppDir() << LL_ENDL; LL_DEBUGS2("AppInit","Directories") << " LindenUserDir: " << getLindenUserDir() << LL_ENDL; LL_DEBUGS2("AppInit","Directories") << " TempDir: " << getTempDir() << LL_ENDL; LL_DEBUGS2("AppInit","Directories") << " CAFile: " << getCAFile() << LL_ENDL; LL_DEBUGS2("AppInit","Directories") << " SkinDir: " << getSkinDir() << LL_ENDL; #if LL_LIBXUL_ENABLED LL_DEBUGS2("AppInit","Directories") << " HTML Path: " << getExpandedFilename( LL_PATH_HTML, "" ) << llendl; LL_DEBUGS2("AppInit","Directories") << " Mozilla Profile Path: " << getExpandedFilename( LL_PATH_MOZILLA_PROFILE, "" ) << llendl; #endif }
/** * @internal * @brief Mac version. Extracts the user application execution and data path. * * They are stored in userDataPath and userExecPath attributes. */ void ResourceManager::extractUserAppPathMAC() { char bundlePath[2048]; char exePath[2048]; char resourcesPath[2048]; CFBundleRef mainBundle = CFBundleGetMainBundle(); assert( mainBundle ); // Get URLs CFURLRef mainBundleURL = CFBundleCopyBundleURL( mainBundle); assert( mainBundleURL); CFURLRef exeURL = CFBundleCopyExecutableURL( mainBundle); assert( exeURL); CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL( mainBundle); assert( resourcesURL); // Get Paths into strings CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle); assert( cfStringRef); CFStringRef cfExePathRef = CFURLCopyFileSystemPath( exeURL, kCFURLPOSIXPathStyle); assert( cfExePathRef); CFStringRef cfResourcesPathRef = CFURLCopyFileSystemPath( resourcesURL, kCFURLPOSIXPathStyle); assert( cfResourcesPathRef); CFStringGetCString( cfStringRef, bundlePath, 1024, kCFStringEncodingASCII); CFStringGetCString( cfExePathRef, exePath, 1024, kCFStringEncodingASCII); CFStringGetCString( cfResourcesPathRef, resourcesPath, 1024, kCFStringEncodingASCII); // Release resources CFRelease( mainBundleURL); CFRelease( exeURL); CFRelease( cfStringRef); CFRelease( cfExePathRef); CFRelease( cfResourcesPathRef); userExecPath = bundlePath; //userExecPath = exePath; std::string::size_type lastSlashPos = userExecPath.find_last_of("/"); userExecPath = userExecPath.substr(0, lastSlashPos); userExecPath = userExecPath + "/"; //userDataPath = userExecPath + userResourcesDirName; resourcesPathInBundle = String(bundlePath) + "/" + String(resourcesPath) + "/"; //userDataPath = String(bundlePath) + "/" + String(resourcesPath) + "/data/"; userDataPath = String(bundlePath) + "/" + userResourcesDirName; //libDataPath = String(bundlePath) + "/" + String(resourcesPath) + "/cing_bin/data/"; libDataPath = String(bundlePath) + "/../../../../cing_bin/data/"; // Log some info LOG( "Exec Path %s", exePath ); LOG( "Bundle Path %s", bundlePath ); LOG( "Resources Path %s", resourcesPath ); LOG( "User Data Path %s", userDataPath.c_str() ); const char* curentDir = getWorkingDir().c_str(); LOG( "Current Working Dir: %s", getWorkingDir().c_str() ); }
bool MolecularFileDialog::writeFile() { list<Composite*>& selection = getMainControl()->getMolecularControlSelection(); if (selection.size() != 1 || !RTTI::isKindOf<System> (*selection.begin())) { setStatusbarText((String)tr("Not a single system selected! Aborting writing..."), true); return false; } const System& system = *(const System*) (*selection.begin()); String file_name = getWorkingDir(); file_name += FileSystem::PATH_SEPARATOR; file_name += system.getName(); file_name += ".pdb"; QString s = QFileDialog::getSaveFileName( 0, tr("Choose a filename to save the selected system"), file_name.c_str(), getSupportedFileFormats().c_str()); if (s == QString::null) return false; setStatusbarText((String)tr("writing file...")); String filename = ascii(s); setWorkingDirFromFilename_(filename); String filter(filename); while (filter.has(FileSystem::PATH_SEPARATOR)) { filter = filter.after(FileSystem::PATH_SEPARATOR); } String filename_without_path = filter; while (filter.has('.')) { filter = filter.after("."); } bool result = false; if (filter == "PDB" || filter == "pdb" || filter == "ent" || filter == "ENT" || filter == "brk" || filter == "BRK") { result = writePDBFile(filename, system); } else if (filter.hasSubstring("HIN") || filter.hasSubstring("hin")) { result = writeHINFile(filename, system); } else if (filter.hasSubstring("MOL2") || filter.hasSubstring("mol2")) { result = writeMOL2File(filename, system); } else if (filter.hasSubstring("MOL") || filter.hasSubstring("mol")) { result = writeMOLFile(filename, system); } else if (filter.hasSubstring("SDF") || filter.hasSubstring("sdf")) { result = writeSDFile(filename, system); } else if (filter.hasSubstring("AC") || filter.hasSubstring("ac")) { result = writeACFile(filename, system); } else if (filter.hasSubstring("XYZ") || filter.hasSubstring("xyz")) { result = writeXYZFile(filename, system); } else { if (filter == filename_without_path) { filename += ".pdb"; result = writePDBFile(filename, system); } else { setStatusbarText((String)tr("Unknown file format, please set the file extension accordingly to type, aborting..."), true); return false; } } if (!result) { return false; } setStatusbarText(String(system.countAtoms()) + " " + (String)tr("atoms written to file") + " \"" + filename + "\"", true); return true; }
void Awstats::config(HttpVHost *pVHost, int val, char* achBuf, const XmlNode *pAwNode, char* iconURI, const char* vhDomain, int vhAliasesLen ) { const char *pURI; const char *pValue; char *p; int handlerType; int len = strlen( achBuf ); int iChrootLen = 0; if ( HttpGlobals::s_psChroot != NULL ) iChrootLen = HttpGlobals::s_psChroot->len(); setMode( val ); if ( achBuf[len - 1] == '/' ) achBuf[len - 1] = 0; setWorkingDir( achBuf ); pURI = pAwNode->getChildValue( "awstatsURI" ); if ( ( !pURI ) || ( *pURI != '/' ) || ( * ( pURI + strlen( pURI ) - 1 ) != '/' ) || ( strlen( pURI ) > 100 ) ) { ConfigCtx::getCurConfigCtx()->log_warn( "AWStats URI is invalid" ", use default [/awstats/]." ); iconURI[9] = 0;; pURI = iconURI; } setURI( pURI ); if ( val == AWS_STATIC ) { handlerType = HandlerType::HT_NULL; strcat( achBuf, "/html/" ); } else { ConfigCtx::getCurConfigCtx()->getValidPath( achBuf, "$SERVER_ROOT/add-ons/awstats/wwwroot/cgi-bin/", "AWStats CGI-BIN directory" ); if ( pVHost->getRootContext().determineMime( "pl", NULL )->getHandler()->getHandlerType() ) handlerType = HandlerType::HT_NULL; else handlerType = HandlerType::HT_CGI; } HttpContext *pContext = pVHost->addContext( pURI, handlerType, &achBuf[iChrootLen], NULL, 1 ); p = achBuf; if ( ConfigCtx::getCurConfigCtx()->getLongValue( pAwNode, "securedConn", 0, 1, 0 ) == 1 ) { p += safe_snprintf( achBuf, 8192, "rewriteCond %%{HTTPS} !on\n" "rewriteCond %%{HTTP:X-Forwarded-Proto} !https\n" "rewriteRule ^(.*)$ https://%%{SERVER_NAME}%%{REQUEST_URI} [R,L]\n" ); } if ( val == AWS_STATIC ) { safe_snprintf( p, &achBuf[8192] - p, "RewriteRule ^$ awstats.%s.html\n", pVHost->getName() ); } else { safe_snprintf( p, &achBuf[8192] - p, "RewriteRule ^$ awstats.pl\n" "RewriteCond %%{QUERY_STRING} !configdir=\n" "RewriteRule ^awstats.pl " "$0?config=%s&configdir=%s/conf [QSA]\n", pVHost->getName(), getWorkingDir() + iChrootLen ); pContext->setUidMode( UID_DOCROOT ); } pContext->enableRewrite( 1 ); pContext->configRewriteRule( pVHost->getRewriteMaps(), achBuf ); pValue = pAwNode->getChildValue( "realm" ); if ( pValue ) pVHost->configAuthRealm( pContext, pValue ); pValue = pAwNode->getChildValue( "siteDomain" ); if ( !pValue ) { ConfigCtx::getCurConfigCtx()->log_warn( "SiteDomain configuration is invalid" ", use default [%s].", vhDomain ); pValue = vhDomain; } else { ConfigCtx::getCurConfigCtx()->expandDomainNames( pValue, achBuf, 4096 ); pValue = achBuf; } setSiteDomain( pValue ); pValue = pAwNode->getChildValue( "siteAliases" ); int needConvert = 1; if ( !pValue ) { if ( vhAliasesLen == 0 ) { safe_snprintf( achBuf, 8192, "127.0.0.1 localhost REGEX[%s]", getSiteDomain() ); ConfigCtx::getCurConfigCtx()->log_warn( "SiteAliases configuration is invalid" ", use default [%s].", achBuf ); pValue = achBuf; needConvert = 0; } else pValue = "$vh_aliases"; } if ( needConvert ) { ConfigCtx::getCurConfigCtx()->expandDomainNames( pValue, &achBuf[4096], 4096, ' ' ); ConfigCtx::getCurConfigCtx()->convertToRegex( &achBuf[4096], achBuf, 4096 ); pValue = achBuf; ConfigCtx::getCurConfigCtx()->log_info( "SiteAliases is set to '%s'", achBuf ); } setAliases( pValue ); val = ConfigCtx::getCurConfigCtx()->getLongValue( pAwNode, "updateInterval", 3600, 3600 * 24, 3600 * 24 ); if ( val % 3600 != 0 ) val = ( ( val + 3599 ) / 3600 ) * 3600; setInterval( val ); val = ConfigCtx::getCurConfigCtx()->getLongValue( pAwNode, "updateOffset", 0, LONG_MAX, 0 ); if ( val > getInterval() ) val %= getInterval(); setOffset( val ); pVHost->setAwstats( this ); }
void AbstractEngine::writeRestartFile() { GreasyTask *task; map<int,GreasyTask*>::iterator it; list<int> dependants; set<GreasyTask*> invalidTasks; list<int>::iterator lit; set<GreasyTask*>::iterator sit; int nindex; ofstream rstfile( restartFile.c_str(), ios_base::out); log->record(GreasyLog::devel, "AbstractEngine::writeRestartFile", "Entering..."); if (!rstfile.is_open()) { log->record(GreasyLog::error, "Could not create restart file " + restartFile); return; } log->record(GreasyLog::info, "Creating restart file " + restartFile + "..."); string logFile = "Standard Error"; if (config->keyExists("LogFile")&&((config->getValue("LogFile") != ""))) { logFile = config->getValue("LogFile"); //Check for a relative path if ((GreasyRegex::match(logFile,"^[:blank:]*/(.*)$")=="")) logFile = getWorkingDir() + logFile; } rstfile << "# " << endl; rstfile << "# Greasy restart file generated at "<< GreasyTimer::now() << endl; rstfile << "# Original task file: " << getWorkingDir() << "/" << taskFile << endl; rstfile << "# Log file: " << logFile << endl; rstfile << "# " << endl; rstfile << endl; nindex = 7; for (it=taskMap.begin();it!=taskMap.end(); it++) { task = it->second; // Completed tasks will not be recorded in the restart file if (task->getTaskState() == GreasyTask::completed) continue; // Invalid tasks will be treated at the end if (task->getTaskState() == GreasyTask::invalid) { invalidTasks.insert(task); continue; } if (task->getTaskState() == GreasyTask::failed) { rstfile << "# Warning: Task " << task->getTaskId() << " failed" << endl; nindex++; } if (task->getTaskState() == GreasyTask::cancelled) { rstfile << "# Warning: Task " << task->getTaskId() << " was cancelled due to a dependency failure" << endl; nindex++; } // Write the task in the restart with its dependencies if any if (task->hasDependencies()) { rstfile << "[# " << task->dumpDependencies() << " #] "; } rstfile << ((*it).second)->getCommand() << endl; //Update indexes of dependencies to the new lines in the restart dependants = revDepMap[task->getTaskId()]; if (!dependants.empty()) { for(lit=dependants.begin();lit!=dependants.end();lit++) { taskMap[*lit]->removeDependency(task->getTaskId()); taskMap[*lit]->addDependency(nindex); } } nindex++; } if (!invalidTasks.empty()) { rstfile << endl << "# Invalid tasks were found. Check these lines on " << taskFile << ": " << endl << "# "; bool first = true; for (sit=invalidTasks.begin();sit!=invalidTasks.end(); sit++) { task = *sit; if (first) { rstfile << toString(task->getTaskId()); first = false; } else { rstfile << ", " << toString(task->getTaskId()); } } rstfile << endl; } rstfile << endl << "# End of restart file" << endl; // close restart file; rstfile.close(); log->record(GreasyLog::info, "Restart file created"); log->record(GreasyLog::devel, "AbstractEngine::writeRestartFile", "Exiting..."); }
QString NewProjectDialog::getProjectFullPath() const { return QDir::fromNativeSeparators(QDir(getWorkingDir()+"/"+getProjectName()).path()); }