CScriptMgr::CScriptMgr() { #ifndef TOOLWORKDIR _chdir("../"); #endif m_ScriptApp = new CScriptAppServer("etc/gas/GasConfig.xml","etc/gas/","1"); ConfigurePath(); RegistShell(); //Run(); }
/** * @param argc argument count * @param argv array of argument strings * * Checks if a demo SDF file or a startscript has * been specified on the command line */ void SpringApp::CheckCmdLineFile(int argc, char *argv[]) { // Check if the commandline parameter is specifying a demo file #ifdef _WIN32 // find the correct dir char exe[128]; GetModuleFileName(0, exe, sizeof(exe)); int a,s = strlen(exe); for (a=s-1;a>0;a--) // Running in gdb causes the last dir separator to be a forward slash. if (exe[a] == '\\' || exe[a] == '/') break; if (a > 0) { string path(exe, exe+a); if (path.at(0) == '"') path.append(1,'"'); _chdir(path.c_str()); } // If there are any options, they will start before the demo file name. string cmdLineStr = win_lpCmdLine; string::size_type offset = 0; //Simply assumes that any argument coming after a argument starting with /q is a variable to /q. for(int i=1; i < argc && (argv[i][0] == '/' || (argv[i-1][0] == '/' && argv[i-1][1] == 'q')); i++){ offset += strlen(argv[i]); offset = cmdLineStr.find_first_not_of(' ', offset); if(offset == string::npos) break; } string command; if(offset != string::npos) command = cmdLineStr.substr(offset); if (!command.empty()) { int idx = command.rfind("sdf"); if (idx == command.size()-3) demofile = command; else startscript = command; } #else for (int i = 1; i < argc; i++) if (argv[i][0] != '-') { string command(argv[i]); int idx = command.rfind("sdf"); if (idx == command.size()-3) { demofile = command; } else { startscript = command; } } #endif }
BOOL CDynGestServer::LoadGestureBase(const char *filename) { CleanAll(); FILE* file; file = fopen( filename, "r" ); if (!file ) return FALSE; char gesture_name[256]; //read main file while ( fscanf( file, "%s\n", gesture_name )!=EOF ) { CDynGesture* gesture = new CDynGesture( m_num_states, m_num_mix ); gesture->SetName( gesture_name ); gesture->LoadParams( gesture_name ); //try to load hmm if ( ! _chdir( gesture->GetName() ) ) { if ( gesture->LoadHMM(gesture->GetName() + ".hmm") ) { gesture->m_trained = TRUE; //change value of m_hmmParams control CStereoGRApp* app = (CStereoGRApp*)AfxGetApp(); app->m_hmmParams->m_num_states = gesture->GetHMM()->num_states; app->m_hmmParams->m_num_mix = gesture->GetHMM()->u.state->num_mix; SetHMMParams( app->m_hmmParams->m_num_states, app->m_hmmParams->m_num_mix ); } _chdir( "..\\" ); } AddGesture( gesture ); } fclose( file ); m_loaded_base = filename; return TRUE; }
/** * Dynamically loads the plugin and runs the plugin's init function. * * @param[in] plugin_file Name of plugin dll/dylib/so. TODO:DOC is this correct? see .h * @return 0 if successful, APR error code or error code from the plugin's init function on failure. */ int LLPluginInstance::load(const std::string& plugin_dir, std::string &plugin_file) { pluginInitFunction init_function = NULL; if ( plugin_dir.length() ) { #if LL_WINDOWS // VWR-21275: // *SOME* Windows systems fail to load the Qt plugins if the current working // directory is not the same as the directory with the Qt DLLs in. // This should not cause any run time issues since we are changing the cwd for the // plugin shell process and not the viewer. // Changing back to the previous directory is not necessary since the plugin shell // quits once the plugin exits. _chdir( plugin_dir.c_str() ); #endif }; int result = apr_dso_load(&mDSOHandle, plugin_file.c_str(), gAPRPoolp); if(result != APR_SUCCESS) { char buf[1024]; apr_dso_error(mDSOHandle, buf, sizeof(buf)); LL_WARNS("PluginInstance") << "apr_dso_load of " << plugin_file << " failed with error " << result << " , additional info string: " << buf << LL_ENDL; } if(result == APR_SUCCESS) { result = apr_dso_sym((apr_dso_handle_sym_t*)&init_function, mDSOHandle, PLUGIN_INIT_FUNCTION_NAME); if(result != APR_SUCCESS) { LL_WARNS("PluginInstance") << "apr_dso_sym failed with error " << result << LL_ENDL; } } if(result == APR_SUCCESS) { result = init_function(staticReceiveMessage, (void*)this, &mPluginSendMessageFunction, &mPluginUserData); if((result != APR_SUCCESS) || (mPluginUserData == NULL)) { LL_WARNS("PluginInstance") << "call to init function failed with error " << result << LL_ENDL; } } return (int)result; }
void CreateDir( const std::string& Path ) { if(_chdir(Path.c_str()) == 0) { _chdir("../"); return; } int ret; #ifdef _WIN32 ret = _mkdir( Path.c_str()); #else ret = mkdir( Path.c_str(), 0777 ); #endif if (ret != 0) { printf("Fatal Error: Could not create directory %s check your permissions", Path.c_str()); exit(1); } }
int no_pos() { _chdir("E:\\carData\\TrainImages"); int dim=10; auto ad=getAllfeas(dim); auto data=ad.first; _chdir("E:\\carData\\TestImages\\mytest"); PMStruc pedmd; pedmd.generatePymFromdata(selectVec(data,dim),dim); givescores(pedmd,dim,false,true); return 0; }
int test_dimension_bynumber() { _chdir("E:\\carData\\TrainImages"); auto ad=getAllfeas(32); auto data=ad.first; _chdir("E:\\carData\\TestImages\\mytest"); testDimension(ad,1); testDimension(ad,3); testDimension(ad,7); testDimension(ad,10); testDimension(ad,15); testDimension(ad,20); return 0; }
int _tmain(int argc, _TCHAR* argv[]) { _chdir(ExePath().c_str()); while (true) { Generator::generateWords(); } return 0; }
int main (int argc, char *argv[]) { char strPakDir[MAX_STRING_LENGTH] = "HGSS"; char strCodingList[MAX_STRING_LENGTH] = "pkm.tbl"; char strSrc[MAX_STRING_LENGTH], strDst[MAX_STRING_LENGTH]; char strTable[CODING_LENGTH + 1][10] = {0}; //游戏的对照码表 struct _finddata_t c_file; intptr_t hFile; FILE *fpCodingList; if (NULL == (fpCodingList = fopen (strCodingList, "rb"))) { printf ("Error when reading \"%s\" file.\n", strCodingList); return 0; } getCodingTable (fpCodingList, strTable); //进入文件夹 if(_chdir( strPakDir ) ) { switch (errno) { case ENOENT: printf( "Unable to locate the directory: %s\n", strPakDir ); break; case EINVAL: printf( "Invalid buffer.\n"); break; default: printf( "Unknown error.\n"); } exit (0); } //到这里进入文件夹就成功了 //获取bin文件的句柄 if( (hFile = _findfirst( "*", &c_file )) == -1L ) { } do { if (NULL != strstr(c_file.name, ".txt")) { continue; } strcpy (strSrc, c_file.name); sprintf (strDst, "%s.txt", strSrc); if (0 != (exportTxt (strSrc, strDst, strTable))) { printf ("Error when handle \"%s\" file.\n", strSrc); } }while( _findnext( hFile, &c_file ) == 0 ); return 0; }
int no_app() { _chdir("E:\\carData\\TrainImages"); int dim=0; auto ad=getAllfeas(dim); auto data=ad.first; _chdir("E:\\carData\\TestImages\\mytest"); PMStruc pedmd(PMStruc::postitionSpecific); pedmd.generatePymFromdata(data,dim); givescores(pedmd,dim,false,false); return 0; }
void QuenchFrame::OnSaveROINifti(wxCommandEvent &event) { int result = _chdir("ROIs"); if(!DoFileDialog(_T("Choose ROI filename."),_T("NIFTI (*.nii.gz)|*.nii.gz"),wxSAVE | wxOVERWRITE_PROMPT)) return; if (result == 0) { // If we succeeded in changing the directory, change it back... _chdir(".."); } std::string path = _file_dialog->GetPath().c_str(); size_t foundExtensionNii = path.find(".nii"); size_t foundExtensionHdr = path.find(".hdr"); std::string fName = _file_dialog->GetFilename().c_str(); if (foundExtensionNii == std::string::npos && foundExtensionHdr == std::string::npos) { path = path + ".nii.gz"; fName = fName + ".nii.gz"; } _qCtrlr->SaveCurrentROINifti(path, fName); }
static void fillUNCRootArray(LPSTR lpsz) { char szCurDir[_MAX_PATH]; _getcwd(szCurDir, sizeof(szCurDir)); lstrcpy(szUNCRoot, lpsz); if(szUNCRoot[lstrlen(szUNCRoot) - 1] == '\\') szUNCRoot[lstrlen(szUNCRoot) - 1] = '\0'; for(;;) { LPSTR lptemp = strrchr(szUNCRoot, '\\'); if(lptemp == NULL) break; *lptemp = '\0'; if(_chdir(szUNCRoot) == -1) { *lptemp = '\\'; break; } } _chdir(szCurDir); }
SetDirectory::~SetDirectory() { if (!directory.empty() && !previousDir.empty()) { std::cout << "<chdir("<<previousDir<<")"<<std::endl; #ifndef WIN32 chdir(previousDir.c_str()); #else _chdir(previousDir.c_str()); #endif } }
void FileSystemAbstraction::ChDir(const std::string& dir) { #ifndef _WIN32 const int err = chdir(dir.c_str()); #else const int err = _chdir(StripTrailingSlashes(dir).c_str()); #endif if (err) { throw content_error("Could not chdir into " + dir); } }
void FileSystemHandler::Chdir(const std::string& dir) { #ifndef _WIN32 const int err = chdir(dir.c_str()); #else const int err = _chdir(StripTrailingSlashes(dir).c_str()); #endif if (err) { throw content_error("Could not chdir into SPRING_DATADIR"); } }
bool setWorkingDirectory(const FileName &path) { int result = -1; #ifdef _WIN32 result = _chdir(path.c_str()); #else result = chdir(path.c_str()); #endif return result >= 0; }
//! Changes the current Working Directory to the string given. //! The string is operating system dependent. Under Windows it will look //! like this: "drive:\directory\sudirectory\" //! \return //! Returns true if successful, otherwise false. bool CFileSystem::changeWorkingDirectoryTo(const c8* newDirectory) { bool success=false; #ifdef _IRR_WINDOWS_ success=(_chdir(newDirectory) == 0); #endif #if (defined(LINUX) || defined(MACOSX)) success=(chdir(newDirectory) != 0); #endif return success; }
//! Changes the current Working Directory to the given string. bool CFileSystem::changeWorkingDirectoryTo(const c8* newDirectory) { bool success=false; #ifdef _MSC_VER #if !defined ( _WIN32_WCE ) success=(_chdir(newDirectory) == 0); #endif #else success=(chdir(newDirectory) == 0); #endif return success; }
/* * NAME: P->chdir() * DESCRIPTION: change the current directory (and drive) */ int P_chdir(const char *dir) { char buf[STRINGSZ]; if (path_file(buf, dir) == (char *) NULL || _chdir(buf) < 0) { return -1; } if (buf[1] == ':' && _chdrive(toupper(buf[0]) - 'A' + 1) < 0) { return -1; } return 0; }
bool AnsiFileSystem::SetCurrentDirectory(const char8 * Directory) { #ifdef WIN32 return (_chdir(Directory) == 0); #endif #ifdef LINUX return !(chdir(Directory) == 0); #endif return false; }
void CBranch_patcherDlg::OnDoPatch() { UpdateData( true ); if ( SaveDiff ) { // Save the diff from the richedit saveFile( TEMP_DIFF_FILE ); } // Apply the patch CString patchCmdLine, concatOutput, delPatchErrors; patchCmdLine.Format( "%spatch.exe -c -p%u --verbose < %s > %s 2> %s", PatchExeDir, CvsDiffDirLevel, TEMP_DIFF_FILE, PATCH_RESULT, PATCH_ERRORS ); // needs patch.exe in the path concatOutput.Format( "copy %s+%s %s", PATCH_RESULT, PATCH_ERRORS, PATCH_RESULT ); delPatchErrors.Format( "del %s", PATCH_ERRORS ); CString text; text.Format( "Patch diff to directory %s?\n\nCommand (choose No to copy it into the clipboard):\n%s", m_DestDir, patchCmdLine ); int result; if ( (result = ::MessageBox( m_hWnd, text, "Confirmation", MB_YESNOCANCEL | MB_ICONQUESTION )) == IDYES ) { if ( _chdir( m_DestDir ) == 0 ) { system( patchCmdLine ); system( concatOutput ); system( delPatchErrors ); displayFile( PATCH_RESULT ); SaveDiff = false; m_Display->LineScroll( 0 ); if ( (m_Display->GetLineCount() == 0) || (m_Display->GetLineCount() == 1 && m_Display->LineLength(0)<2) ) { CString s; s.Format( "Nothing was patched.\r\nIf this is not the expected result:\r\n- check if the good patch.exe is in %s\r\n- check if %s exists (generated by previous diff)\r\n- check if C:\\ has enough free space and access rights to write a file.", TEMP_DIFF_FILE ); displayMessage( s ); } else { m_Filename = PATCH_RESULT + ":"; UpdateData( false ); } } else { displayMessage( "Target directory not found" ); } } else if ( result == IDNO ) { SendTextToClipboard( patchCmdLine ); } }
char * DCirfile::PathRight(void) { if (SecFound) return SecFile->PathRight(); if (CurrRight == NULL) return NULL; char *chp = strncpy(NewName(RightLen + 1), CurrRight, RightLen); chp[RightLen] = '\0'; char *currdir = _getcwd(NewName(1024), 1024); char *inidir = this->getBasePath(); int currdrive = _getdrive(); int inidrive = 0; if (stricmp(currdir, inidir) && !PathIsURL(chp) && PathIsRelative(chp)) { // fix rel path if (*(inidir + 1) == ':') inidrive = (toupper(*inidir) - 'A') + 1; if (inidrive && (currdrive != inidrive)) _chdrive(inidrive); _chdir(inidir); char *nref = NewName(MAX_PATH); if (_fullpath(nref, chp, MAX_PATH)) { DeleteName(chp); chp = NewName(nref); } DeleteName(nref); if (inidrive && (currdrive != inidrive)) _chdrive(currdrive); _chdir(currdir); } DeleteName(currdir); return chp; }
int APIENTRY WinMain(HINSTANCE inst, HINSTANCE junk, char *args, int junk2) { char dir[MPR_MAX_FNAME], moduleBuf[MPR_MAX_FNAME], tmp[MPR_MAX_FNAME]; char *cp; int errflg, sleepMsecs, removeOk; errflg = 0; sleepMsecs = 0; removeOk = 0; /* * Get the directory above bin */ GetModuleFileName(0, moduleBuf, sizeof(moduleBuf) - 1); mprGetDirName(tmp, sizeof(tmp), moduleBuf); mprGetDirName(dir, sizeof(dir), tmp); _chdir(dir); if (args && *args) { if (strstr(args, "-r") != 0) { removeOk++; } if ((cp = strstr(args, "-s")) != 0) { do { cp++; } while (isspace(*cp)); sleepMsecs = atoi(cp) * 1000; } } /* * We use removeOk to ensure that someone just running the program won't * do anything bad. */ if (errflg || !removeOk) { fprintf(stderr, "Bad Usage"); return FALSE; } cleanup(); /* * Some products (services) take a while to exit. This is a convenient * way to pause before removing */ if (sleepMsecs) { printf("sleeping for %d msec\n", sleepMsecs); Sleep(sleepMsecs); } return 0; }
void mytest20150607yiqiyibiao() { char fileList[200][260];//200个文件,每个最长名称260,这里必须设置为260,不然会出现问题 char outputFilename[260]; char inputFilename[260]; unsigned int fileListCount = 0; unsigned int fileidx; float initBits = 2.0; int dlen = 0; int oriFileLen; _chdir("TestData\\节点采集_16位数据\\Node9"); myFileGetFileListByType("*.DAT", fileList, &fileListCount); //初始化 DCTBLOCKCOUNT = 40; //对DDS采集的数据,为40*2048 20150607 DQLC_Init(); F4Printf = fopen("log.txt", "w"); for (fileidx = 0; fileidx < fileListCount; fileidx++) { strcpy(outputFilename, fileList[fileidx]); strcat(outputFilename, ".bit"); dlen = DQLC_dctQuan(fileList[fileidx], outputFilename, initBits, 1); //解压数据 strcpy(inputFilename, outputFilename); strcpy(outputFilename, fileList[fileidx]); strcat(outputFilename, ".dec"); DQLC_DeCompress(inputFilename, outputFilename, 1); oriFileLen = myFileGetFileLength(fileList[fileidx]); printf("%s\t\t%f\r\n", fileList[fileidx], dlen / (float)oriFileLen); } //测试数据是否无损 for (fileidx = 0; fileidx < fileListCount; fileidx++) { strcpy(outputFilename, fileList[fileidx]); strcat(outputFilename, ".dec"); printf("%s\t", fileList[fileidx]); myFileCompare(fileList[fileidx], outputFilename); } fclose(F4Printf); getchar(); return; }
int ExecuteCommand( char* path, char* CommandLine, DWORD millisecTimeout, void* envFlags) { int rc; FILE* childOutput = NULL; char putEnvStr[BUFFER_SIZE]; char ExecuteProgramCmdLine[BUFFER_SIZE]; UINT prevmode; prevmode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX); // Always flush output buffers before executing a command. Note: this // shouldn't really be necessary because all output should be buffered // by the COutputBuffer class on a per-thread basis. fflush(stdout); fflush(stderr); strcpy_s(ExecuteProgramCmdLine, "cmd.exe /c "); // for .cmd/.bat scripts strcat_s(ExecuteProgramCmdLine, CommandLine); EnterCriticalSection(&csCurrentDirectory); // If we're doing executable tests, set the TARGET_VM environment variable. // We must do this inside a critical section since the environment is // not thread specific. if ((Mode == RM_EXE) && TargetVM) { sprintf_s(putEnvStr, "TARGET_VM=%s", TargetVM); _putenv(putEnvStr); } rc = _chdir(path); if (rc == 0) { childOutput = PipeSpawn(ExecuteProgramCmdLine, envFlags); } LeaveCriticalSection(&csCurrentDirectory); if (rc != 0) { LogError("Could not change directory to '%s' - errno == %d\n", path, errno); } else if (childOutput != NULL) { rc = FilterThread(childOutput, millisecTimeout); rc = PipeSpawnClose(childOutput, rc == WAIT_TIMEOUT); } SetErrorMode(prevmode); return rc; }
void gmx_chdir(const char *directory) { #ifdef GMX_NATIVE_WINDOWS int rc = _chdir(directory); #else int rc = chdir(directory); #endif if (rc != 0) { gmx_fatal(FARGS, "Cannot change directory to '%s'. Reason: %s", directory, strerror(errno)); } }
SetDirectory::SetDirectory(const std::string& filename) { directory = GetParentDir(filename.c_str()); if (!directory.empty()){ std::cout << ">chdir("<<directory<<")"<<std::endl; previousDir = GetCurrentDir(); #ifndef WIN32 chdir(directory.c_str()); #else _chdir(directory.c_str()); #endif } }
void cDirectoryListing::PopDir( void ) { if( dirs.empty() ) { Console.Error( "cServerDefinition::PopDir called, but dirs is empty" ); Shutdown( FATAL_UOX3_DIR_NOT_FOUND ); } else { _chdir( dirs.top().c_str() ); dirs.pop(); } }
ChangeCurrentDir() { if ( !_getcwd( dir, PATH_LEN ) ) { REPORT_FATAL_ERROR("ERROR: Couldn't get current working directory\n"); } last_slash = strrchr( dir, SLASH ); ASSERT( last_slash, "The current directory doesn't contain slashes" ); *last_slash = 0; if ( _chdir( last_slash-dir == ROOT_DIR_REST ? ROOT_DIR : dir ) ) { REPORT_FATAL_ERROR("ERROR: Couldn't change current working directory (%s)\n", dir ); } }
bool CBrowseDir::SetInitDir(const char *dir) { //先把dir转换为绝对路径 if (_fullpath(m_szInitDir,dir,_MAX_PATH) == NULL) return false; //判断目录是否存在 if (_chdir(m_szInitDir) != 0) return false; //如果目录的最后一个字母不是'\',则在最后加上一个'\' int len=strlen(m_szInitDir); if (m_szInitDir[len-1] != '\\') strcat(m_szInitDir,"\\"); return true; }