stringT pws_os::getcwd() { charT *curdir = _tgetcwd(NULL, 512); // NULL means 512 doesn't matter stringT CurDir(curdir); free(curdir); return CurDir; }
bool CTestResource::LoadFromDirectory (LPCTSTR psz) { bool rc=true; ENTERCRITICAL; DeleteAllInstances(); // Find all the files in directory "psz" and load from each of them TCHAR szOrigDir[256]; _tgetcwd(szOrigDir,sizeof szOrigDir-1); if(0==_tchdir(psz)){ String strFile; void *pHandle; for(bool b=CeCosTestUtils::StartSearch(pHandle,strFile);b;b=CeCosTestUtils::NextFile(pHandle,strFile)){ if(CeCosTestUtils::IsFile(strFile)){ CTestResource *pResource=new CTestResource(_T(""),_T("")); CTestResourceProperties prop(pResource); prop.LoadFromFile(strFile); } } CeCosTestUtils::EndSearch(pHandle); } else { TRACE(_T("Failed to change to %s from %s\n"),psz,szOrigDir); } _tchdir(szOrigDir); LEAVECRITICAL; return rc; }
bool CeCosTestPlatform::LoadFromDir(LPCTSTR pszDir) { bool rc=true; TRACE(_T("CeCosTestPlatform::LoadFromDir %s\n"),pszDir); // Find all the files in directory pszDir and load from each of them TCHAR szOrigDir[256]; _tgetcwd(szOrigDir,sizeof szOrigDir-1); if(0==_tchdir(pszDir)){ String strFile; void *pHandle; for(bool b=CeCosTestUtils::StartSearch(pHandle,strFile);b;b=CeCosTestUtils::NextFile(pHandle,strFile)){ if(CeCosTestUtils::IsFile(strFile)){ CeCosTestPlatform t; t.m_strName=strFile; CeCosTestPlatformProperties prop(&t); if(prop.LoadFromFile(strFile)){ Add(t); } else { ERROR(_T("Illegal platform specification in %s%c%s\n"),pszDir,cPathsep,(LPCTSTR)strFile); rc=false; } } } CeCosTestUtils::EndSearch(pHandle); } else { ERROR(_T("Failed to change to %s from %s\n"),pszDir,szOrigDir); } _tchdir(szOrigDir); return rc; }
KString GetCurrentFolder() { TCHAR Buffer[1024]; _tgetcwd(Buffer, sizeof(Buffer)); return SlashedFolderName(Buffer); }
static void setup_testenv(void **state) { int rc; rc = wipe_testdir(); assert_int_equal(rc, 0); mbchar_t *dir = c_utf8_path_to_locale(CSYNC_TEST_DIR); rc = _tmkdir(dir, MKDIR_MASK); assert_int_equal(rc, 0); assert_non_null(_tgetcwd(wd_buffer, WD_BUFFER_SIZE)); rc = _tchdir(dir); assert_int_equal(rc, 0); c_free_locale_string(dir); /* --- initialize csync */ statevar *mystate = malloc( sizeof(statevar) ); mystate->result = NULL; csync_create(&(mystate->csync), "/tmp/csync1", "/tmp/csync2"); mystate->csync->replica = LOCAL_REPLICA; *state = mystate; }
bool CTestResource::SaveToDirectory (LPCTSTR pszDir) { bool rc=false; ENTERCRITICAL; { // Delete all the files under directory "pszDir" void *pHandle; TCHAR szOrigDir[256]; _tgetcwd(szOrigDir,sizeof szOrigDir-1); if(0==_tchdir(pszDir)){ String strFile; for(bool b=CeCosTestUtils::StartSearch(pHandle,strFile);b;b=CeCosTestUtils::NextFile(pHandle,strFile)){ if(CeCosTestUtils::IsFile(strFile)){ _tunlink(strFile); } } CeCosTestUtils::EndSearch(pHandle); rc=true; for(CTestResource *pResource=pFirstInstance;pResource;pResource=pResource->m_pNextInstance){ CTestResourceProperties prop(pResource); rc&=prop.SaveToFile(pResource->FileName()); } } else { fprintf(stderr,"Failed to change to %s from %s\n",pszDir,szOrigDir); } _tchdir(szOrigDir); } LEAVECRITICAL; return rc; }
bool CeCosTestPlatform::SaveToDir (LPCTSTR pszDir) { bool rc=false; void *pHandle; TCHAR szOrigDir[256]; _tgetcwd(szOrigDir,sizeof szOrigDir-1); if(0==_tchdir(pszDir)){ // Delete all the files under directory "pszDir" String strFile; for(bool b=CeCosTestUtils::StartSearch(pHandle,strFile);b;b=CeCosTestUtils::NextFile(pHandle,strFile)){ if(CeCosTestUtils::IsFile(strFile)){ _tunlink(strFile); } } CeCosTestUtils::EndSearch(pHandle); rc=true; // Rewrite the files for(int i=0;i<(signed)arPlatforms.size();i++){ CeCosTestPlatform &t=arPlatforms[i]; CeCosTestPlatformProperties prop(&t); rc&=prop.SaveToFile(t.Name()); } } else { ERROR(_T("Failed to change to %s from %s\n"),pszDir,szOrigDir); } return rc; }
xsTChar *xsGetLocalDataPath(xsTChar *buf) { xsTChar *dir = _tgetcwd(buf, XS_MAX_PATH); if (dir != NULL) xsTcsCat(buf, xsT("\\")); return dir; }
CL_String CL_Directory::get_current() { #ifdef WIN32 TCHAR cwd_buffer[MAX_PATH]; #ifdef _CRT_INSECURE_DEPRECATE if (_tgetcwd(cwd_buffer, MAX_PATH) == NULL) throw CL_Exception("Working dir is more than legal length !"); #else if (_tgetcwd(cwd_buffer, MAX_PATH) == NULL) throw CL_Exception("Working dir is more than legal length !"); #endif #else char cwd_buffer[MAX_PATH]; if (getcwd(cwd_buffer, MAX_PATH) == NULL) throw CL_Exception("Working dir is more than legal length !"); #endif return cwd_buffer; }
BOOL CTeapotApp::InitWorkDir(const _TCHAR* dir) { _TCHAR* oldDir = _tgetcwd(0, 0); if (oldDir == 0) return FALSE; m_OldWorkDir = oldDir; free(oldDir); return (_tchdir(dir) == 0); }
TCHAR* get_current_dir() { TCHAR* result = (TCHAR*)malloc(sizeof(TCHAR)*_MAX_PATH); if(_tgetcwd(result,_MAX_PATH)) { return result; } else { free(result); return NULL; } }
bool FolderExists(const KString& FolderName) { if(FolderName.IsEmpty()) return false; TCHAR CurDir[1024]; _tgetcwd(CurDir, sizeof(CurDir) - 1); const bool bResult = _tchdir(UnslashedFolderName(FolderName)) ? false : true; _tchdir(CurDir); return bResult; }
cl::Kernel compileKernelCpp(const MyOclContext &ocl, const char *kernelFile, const char *kernelName, std::string compileOpt) { cl::Program program; try { std::ifstream infile(kernelFile); if (infile.fail()) { TCHAR cCurrentPath[FILENAME_MAX]; #if defined(_WIN32) if (_tgetcwd(cCurrentPath, sizeof(cCurrentPath) / sizeof(TCHAR))) #else if (getcwd(cCurrentPath, sizeof(cCurrentPath) / sizeof(TCHAR))) #endif { std::wcout << _T( "CWD=" ) << cCurrentPath << std::endl; }; std::cout << "ERROR: can't open file '" << kernelFile << std::endl; throw; }; std::string str((std::istreambuf_iterator<char>(infile)), std::istreambuf_iterator<char>()); const char* kStr = str.c_str(); cl::Program::Sources source(1, std::make_pair(kStr,strlen(kStr))); program = cl::Program(ocl._context, source); std::vector<cl::Device> devices; devices.push_back(ocl._device); compileOpt += " -x clc++"; program.build(devices, compileOpt.c_str()); cl::Kernel kernel(program, kernelName); return kernel; } catch (cl::Error err) { std::cerr << "ERROR: "<< err.what()<< "("<< err.err()<< ")"<< std::endl; std::cout << "Error building program\n"; std::cout << "Build Status: " << program.getBuildInfo<CL_PROGRAM_BUILD_STATUS>(ocl._device) << std::endl; std::cout << "Build Options:\t" << program.getBuildInfo<CL_PROGRAM_BUILD_OPTIONS>(ocl._device) << std::endl; std::cout << "Build Log:\t " << program.getBuildInfo<CL_PROGRAM_BUILD_LOG>(ocl._device) << std::endl; return cl::Kernel(); } };
/* * @implemented * * _getdcwd (MSVCRT.@) * * Get the current working directory on a given disk. * * PARAMS * drive [I] Drive letter to get the current working directory from. * buf [O] Destination for the current working directory. * size [I] Length of drive in characters. * * RETURNS * Success: If drive is NULL, returns an allocated string containing the path. * Otherwise populates drive with the path and returns it. * Failure: NULL. errno indicates the error. */ _TCHAR* _tgetdcwd(int drive, _TCHAR * buf, int size) { static _TCHAR* dummy; TRACE(":drive %d(%c), size %d\n",drive, drive + 'A' - 1, size); if (!drive || drive == _getdrive()) return _tgetcwd(buf,size); /* current */ else { _TCHAR dir[MAX_PATH]; _TCHAR drivespec[] = _T("A:"); int dir_len; drivespec[0] += drive - 1; if (GetDriveType(drivespec) < DRIVE_REMOVABLE) { __set_errno(EACCES); return NULL; } /* GetFullPathName for X: means "get working directory on drive X", * just like passing X: to SetCurrentDirectory means "switch to working * directory on drive X". -Gunnar */ dir_len = GetFullPathName(drivespec,MAX_PATH,dir,&dummy); if (dir_len >= size || dir_len < 1) { __set_errno(ERANGE); return NULL; /* buf too small */ } TRACE(":returning '%s'\n", dir); if (!buf) return _tcsdup(dir); /* allocate */ _tcscpy(buf,dir); } return buf; }
void MyLib::ImportLycByPath(std::tstring path) { LPCTSTR pszFolder=path.c_str(); TCHAR* curPath=new TCHAR[MAX_PATH]; _tgetcwd(curPath,MAX_PATH); //改变当前目录 _tchdir(pszFolder); BOOL findResult=FALSE; WIN32_FIND_DATA findFileData; HANDLE hFind; hFind=::FindFirstFile(_T("*.lrc"),&findFileData); if(hFind!=INVALID_HANDLE_VALUE){ findResult=TRUE; while(findResult) { TCHAR *_findName=new TCHAR[MAX_PATH]; _tcscpy(_findName,findFileData.cFileName); TCHAR *pathName=new TCHAR[MAX_PATH+1]; _tcscpy(pathName,pszFolder); _tcscat(pathName,_T("\\")); _tcscat(pathName,_findName); //std::tstring str(pathName); std::tstring str(pathName); MyLib::shared()->dataPaths.push_back(str); findResult=FindNextFile(hFind,&findFileData); } FindClose(hFind); } //回复当前目录 _tchdir(curPath); }
int main(int argc, char **argv) { TCHAR *fn, *cwd; state *s; int count, status = STATUS_OK; /* Because the main() function can handle wchar_t arguments on Win32, we need a way to reference those values. Thus we make a duplciate of the argc and argv values. */ #ifndef __GLIBC__ __progname = basename(argv[0]); #endif s = (state *)malloc(sizeof(state)); if (NULL == s) { // We can't use fatal_error because it requires a valid state print_status("%s: Unable to allocate state variable", __progname); return STATUS_INTERNAL_ERROR; } if (initialize_state(s)) { print_status("%s: Unable to initialize state variable", __progname); return STATUS_INTERNAL_ERROR; } if (process_command_line(s,argc,argv)) { print_status("%s: Unable to process command line arguments", __progname); return STATUS_INTERNAL_ERROR; } #ifdef _WIN32 if (prepare_windows_command_line(s)) fatal_error(s,"%s: Unable to process command line arguments", __progname); #else s->argc = argc; s->argv = argv; #endif /* Anything left on the command line at this point is a file or directory we're supposed to process. If there's nothing specified, we should tackle standard input */ if (optind == argc) hash_stdin(s); else { MD5DEEP_ALLOC(TCHAR,fn,PATH_MAX); MD5DEEP_ALLOC(TCHAR,cwd,PATH_MAX); cwd = _tgetcwd(cwd,PATH_MAX); if (NULL == cwd) fatal_error(s,"%s: %s", __progname, strerror(errno)); count = optind; while (count < s->argc) { generate_filename(s,fn,cwd,s->argv[count]); #ifdef _WIN32 status = process_win32(s,fn); #else status = process_normal(s,fn); #endif // if (status != STATUS_OK) // return status; ++count; } free(fn); free(cwd); } /* We only have to worry about checking for unused hashes if one of the matching modes was enabled. We let the display_not_matched function determine if it needs to display anything. The function also sets our return values in terms of inputs not being matched or known hashes not being used */ if ((s->mode & mode_match) || (s->mode & mode_match_neg)) s->return_value = finalize_matching(s); return s->return_value; }
int main(int argc, char **argv) { int count, status = EXIT_SUCCESS; TCHAR *fn; state *s; /* Because the main() function can handle wchar_t arguments on Win32, we need a way to reference those values. Thus we make a duplciate of the argc and argv values. */ #ifndef __GLIBC__ __progname = basename(argv[0]); #endif s = (state *)malloc(sizeof(state)); if (NULL == s) { // We can't use fatal_error because it requires a valid state print_status("%s: Unable to allocate state variable", __progname); return EXIT_FAILURE; } if (initialize_state(s)) { print_status("%s: Unable to initialize state variable", __progname); return EXIT_FAILURE; } process_command_line(s,argc,argv); if (initialize_hashing_algorithms(s)) return EXIT_FAILURE; if (primary_audit == s->primary_function) setup_audit(s); #ifdef _WIN32 if (prepare_windows_command_line(s)) fatal_error(s,"%s: Unable to process command line arguments", __progname); check_wow64(s); #else s->argc = argc; s->argv = argv; #endif MD5DEEP_ALLOC(TCHAR,s->cwd,PATH_MAX); s->cwd = _tgetcwd(s->cwd,PATH_MAX); if (NULL == s->cwd) fatal_error(s,"%s: %s", __progname, strerror(errno)); /* Anything left on the command line at this point is a file or directory we're supposed to process. If there's nothing specified, we should tackle standard input */ if (optind == argc) hash_stdin(s); else { MD5DEEP_ALLOC(TCHAR,fn,PATH_MAX); count = optind; while (count < s->argc) { generate_filename(s,fn,s->cwd,s->argv[count]); #ifdef _WIN32 status = process_win32(s,fn); #else status = process_normal(s,fn); #endif ++count; } free(fn); } if (primary_audit == s->primary_function) status = display_audit_results(s); return status; }
BOOL CAocTMApp::InitInstance() { // InitCommonControlsEx() is required on Windows XP if an application // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // Set this to include all the common control classes you want to use // in your application. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinApp::InitInstance(); if (!AfxSocketInit()) { AfxMessageBox(IDP_SOCKETS_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need // Change the registry key under which our settings are stored // TODO: You should modify this string to be something appropriate // such as the name of your company or organization SetRegistryKey(_T("AOC Team Manager")); CFile f; if(!f.Open(DB_NAME, CFile::modeRead)) { CFileDialog dbDlg(true, _T(".aoc"), DB_NAME, 0, _T("AOC Database File (*.aoc)|*.aoc|All Files (*.*)|*.*||")); if(dbDlg.DoModal() == IDCANCEL) return FALSE; DB_File = dbDlg.GetPathName(); } else { f.Close(); TCHAR cwd[256]; _tgetcwd(cwd, 256); DB_File = CString(cwd) + _T("\\") + DB_NAME; } Engine = PersistentEngineFactory::CreatePersistentEngine(_T("SQLite")); if(Engine == NULL) AfxMessageBox(_T("Database Engine Initialize FAILED.")); Engine->CreateNewDatabase(DB_File); /* while(!Engine->Open(DB_File)) { CFileDialog dbDlg(true, _T(".aoc"), _T("doctors.aoc"), 0, _T("AOC (Database File) | *.aoc")); if(dbDlg.DoModal() == IDCANCEL) { //create a database Engine->CreateNewDatabase(DB_File); break; } DB_File = dbDlg.GetPathName(); } */ //pubb, 07-08-04, open once, and close once during the program runs //huangjie, 07-08-03, we must open database explicit Engine-> Open(DB_File); Config.Load(Engine); Recgames.Initialize(); Recgames.Load(Engine); /* pubb, 07-07-27 * load Players into PlayerDatabase from DB. only save back (and update) when exiting */ Players.Load(Engine); //pubb, 07-09-18, set related recgame db Players.m_pRecgameDB = &Recgames; /* pubb, 07-07-31 * for grouping */ ClearCurrentPlayers(); CAocTMDlg dlg; m_pMainWnd = &dlg; INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: Place code here to handle when the dialog is // dismissed with OK } else if (nResponse == IDCANCEL) { // TODO: Place code here to handle when the dialog is // dismissed with Cancel } //pubb, 07-08-04 Players.Save(Engine); //pubb, 07-09-18 Recgames.Save(Engine); Config.Save(Engine); //pubb, 07-09-18, explicitly clear memory Recgames.Free(); Players.Free(); /* pubb, 07-08-03 */ Engine->Close(); delete Engine; // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; }
int main(int argc, char **argv) { int count, status, goal = argc; state *s; TCHAR *fn, *cwd; #ifndef __GLIBC__ __progname = basename(argv[0]); #endif s = (state *)malloc(sizeof(state)); if (NULL == s) fatal_error("%s: Unable to allocate state variable", __progname); if (initialize_state(s)) fatal_error("%s: Unable to initialize state variable", __progname); process_cmd_line(s,argc,argv); #ifdef _WIN32 if (prepare_windows_command_line(s)) fatal_error("%s: Unable to process command line arguments", __progname); #else s->argc = argc; s->argv = argv; #endif // Anything left on the command line at this point is a file // or directory we're supposed to process. If there's nothing // specified, we should tackle standard input if (optind == argc) { status = process_stdin(s); } else { MD5DEEP_ALLOC(TCHAR,fn,PATH_MAX); MD5DEEP_ALLOC(TCHAR,cwd,PATH_MAX); cwd = _tgetcwd(cwd,PATH_MAX); if (NULL == cwd) fatal_error("%s: %s", __progname, strerror(errno)); count = optind; // The signature comparsion mode needs to use the command line // arguments and argument count. We don't do wildcard expansion // on it on Win32 (i.e. where it matters). The setting of 'goal' // to the original argc occured at the start of main(), so we just // need to update it if we're *not* in signature compare mode. if (!(s->mode & mode_sigcompare)) { goal = s->argc; } while (count < goal) { if (MODE(mode_sigcompare)) match_load(s,argv[count]); else if (MODE(mode_compare_unknown)) match_compare_unknown(s,argv[count]); else { generate_filename(s,fn,cwd,s->argv[count]); #ifdef _WIN32 status = process_win32(s,fn); #else status = process_normal(s,fn); #endif } ++count; } // If we processed files, but didn't find anything large enough // to be meaningful, we should display a warning message to the user. // This happens mostly when people are testing very small files // e.g. $ echo "hello world" > foo && ssdeep foo if ( ! s->found_meaningful_file && s->processed_file) { print_error(s,"%s: Did not process files large enough to produce meaningful results", __progname); } } // If the user has requested us to compare signature files, use // our existng code to pretty-print directory matching to do the // work for us. if (s->mode & mode_sigcompare) s->mode |= mode_match_pretty; if (s->mode & mode_match_pretty) match_pretty(s); return (EXIT_SUCCESS); }
int _tmain(int argc,_TCHAR *argv[]) { int viewrnd=0; int viewprev=0; int viewhelp=0; int viewini=0; int viewlist=0; int viewindex=0; int viewnext=0; int fcount=0; int next=1; int reload=0; _TCHAR *pageviewer=(_TCHAR*)malloc(_MAX_FNAME); _TCHAR *lastdir=(_TCHAR *)malloc(_MAX_PATH); _TCHAR *inifile=_tgetenv(_T("APPDATA")); _TCHAR *cmdline=(_TCHAR*)malloc(_MAX_FNAME); _TCHAR *defaultfile=(_TCHAR*)malloc(_MAX_FNAME); _TCHAR *searchfor=(_TCHAR*)malloc(_MAX_FNAME); _TCHAR **filelist; FILE *appout; APPINI status; defaultfile[0]=NIL; pageviewer[0]=NIL; lastdir[0]=NIL; cmdline[0]=NIL; status.viewer[0]=NIL; status.workdir[0]=NIL; status.filename[0]=NIL; #ifdef _DEBUG appout=_tfopen(_T("text.txt"),_T("wb")); #else appout=stdout; #endif _tcscat(inifile,_T("\\") _T(APPNAME)); _tmkdir(inifile); _tcscat(inifile,_T("\\rview.ini")); while (--argc>0) { /*if argv start at '-')*/ if (argv[argc][0]==_T('-')) { switch(argv[argc][1]) { case _T('r'): case _T('R'): reload=1; break; case _T('h'): case _T('H'): viewhelp=1; break; case _T('v'): case _T('V'): viewini=1; break; case _T('l'): case _T('L'): viewlist=1; break; case _T('n'): case _T('N'): viewnext=1; break; case _T('p'): case _T('P'): viewprev=1; break; case _T('z'): case _T('Z'): viewrnd=1; break; case _T('c'): case _T('C'): _tcscpy(pageviewer,(_TCHAR*)&(argv[argc][2])); break; case _T('f'): case _T('F'): _tcscpy(defaultfile,(_TCHAR*)&(argv[argc][2])); break; } } else viewindex=_ttoi(argv[argc]); } if (viewhelp==1) { fprintf(appout,"%s\n",APPINFO); fprintf(appout,"%s\n",APPHELP); return 0; } _tgetcwd(lastdir,_MAX_PATH); if (loadpre(&status,inifile)==0) { status.workdir[0] =NIL;// _tcscpy(status.workdir,lastdir); status.viewer[0]=NIL;//_tcscpy(status.viewer,pageviewer); status.filename[0] = NIL; } #ifndef _DEBUG _ftprintf(appout,_T("CURLINE:%d\n"),__LINE__); _ftprintf(appout,_T("Viewer:%s\n"),status.viewer); _ftprintf(appout,_T("Workdir:%s\n"),status.workdir); _ftprintf(appout,_T("Filename:%s\n"),status.filename); #endif if (status.workdir[0]==NIL) _tcscpy(status.workdir ,lastdir); if (pageviewer[0]!=NIL) _tcscpy(status.viewer,pageviewer); else if (status.viewer[0]==NIL) _tcscpy(status.viewer,DEFAULTVIEWER); if (viewini==1) { _ftprintf(appout,_T("DefaultViewer:%s\nWorkDir:%s\nLastFile:%s"),status.viewer,status.workdir,status.filename ); savecur(&status,inifile); return 0; } if (reload==1) { int c=0; fprintf(appout,"原先目录是:"); _ftprintf(appout,_T("%s\n"), status.workdir); fprintf(appout,"当前目录是:"); _ftprintf(appout,_T("%s\n"),lastdir); fprintf(appout,"确定要将当前目录设定为工作目录?(Y/N)"); //fflush(stdin); c=_fgettchar(); if (c==_T('Y') || c==_T('y')) { _tcscpy(status.workdir,lastdir); status.filename[0] = NIL; savecur(&status,inifile); } } //_chdir(status.workdir); //DEBUGStr(status.workdir) if (defaultfile[0]!=NIL) _tcscpy(status.filename ,defaultfile); if (status.filename[0]==NIL) viewnext=1; /* DEBUGInt(viewnext); DEBUGInt(viewlist); DEBUGInt(viewrnd); DEBUGInt(viewindex);*/ if ((viewlist)||(viewrnd)||(viewindex)||(viewnext)) { searchfor=buildpath(searchfor,status.workdir,WILDNAME); #ifdef _DEBUG //DEBUGStr(status.workdir); _ftprintf(appout,_T("%s\n"),status.workdir); _ftprintf(appout,_T("%s\n"),WILDNAME); _ftprintf(appout,_T("%s\n"),searchfor); #endif fcount=countfile(searchfor,_A_ARCH); if (fcount<=0) return 0; filelist=(_TCHAR **)malloc(sizeof(_TCHAR*)*(fcount+1)); fcount=findfile(searchfor,_A_ARCH,filelist,fcount); qsort((void*)filelist,(size_t) fcount,sizeof(_TCHAR*),(int(_cdecl*)(const void*,const void*))&wcscmp); //viewlist if (viewlist==1) { int i; for (i=0;i<fcount;i++){ _ftprintf(appout,_T("[%4d]:%s\n"),i+1,filelist[i]); } return(0); } else if (viewindex>0) { //viewindex next=viewindex-1; } else if (viewrnd==1) { //viewrnd srand( (unsigned)time( NULL ) ); next= rand( ) % fcount; } else if (status.filename[0]==NIL) { next=0; } else if (viewnext==1) { next=getindex(status.filename,filelist,fcount)+1; } else if (viewprev==1) { next=getindex(status.filename,filelist,fcount)-1; } if ((next>fcount-1) || next<0 ) next=0; _tcscpy(status.filename ,filelist[next]); } /*DEBUGStr(status.viewer ) DEBUGStr(status.workdir ) DEBUGStr(status.filename )*/ savecur(&status,inifile); defaultfile=buildpath(defaultfile,status.workdir ,status.filename ); _stprintf(cmdline,_T("%s \"%s\""),status.viewer,defaultfile); //printf("%s:\n",status.filename); #ifdef _DEBUG _ftprintf(appout,_T("Viewer:%s\n"),status.viewer); _ftprintf(appout,_T("Workdir:%s\n"),status.workdir); _ftprintf(appout,_T("Filename:%s\n"),status.filename); _ftprintf(appout,_T("DefaultFile:%s\n"),defaultfile); _ftprintf(appout,_T("Cmdline:%s\n"),cmdline); #endif system(cmdline); _ftprintf(appout,_T("[%s]\n"),defaultfile); fclose(appout); return (0); }