void MaxAWDExporter::CopyViewer(bool network) { char awdDrive[4]; char awdPath[1024]; char awdName[256]; char dleFullPath[1024]; char dleDrive[4]; char dlePath[1024]; char tplHtmlPath[1024]; char tplSwfPath[1024]; char tplJsPath[1024]; char outHtmlPath[1024]; char outSwfPath[1024]; char outJsPath[1024]; // Get paths of plug-in DLE file and output AWD file and split into // components to be used to concatenate input and output paths. //TCHAR * dleFullPath_tchar=A2W(_T("")); TCHAR dleFullPath_tchar[1024]; GetModuleFileName(hInstance, dleFullPath_tchar, 1024); char * dleFullPath_ptr=W2A(dleFullPath_tchar); _splitpath_s(dleFullPath_ptr, dleDrive, 4, dlePath, 1024, NULL, 0, NULL, 0); _splitpath_s(awdFullPath, awdDrive, 4, awdPath, 1024, awdName, 256, NULL, 0); // Select which viewer SWF file to copy depending on which sandbox // it should be compiled for (network or local.) char *viewerName = network?"AwayExtensions3dsMax\\AWDHTMLViewer\\viewer_n" : "AwayExtensions3dsMax\\AWDHTMLViewer\\viewer_l"; // Assemble paths for inputs (templates) _makepath_s(tplHtmlPath, 1024, dleDrive, dlePath, "AwayExtensions3dsMax\\AWDHTMLViewer\\template", "html"); _makepath_s(tplSwfPath, 1024, dleDrive, dlePath, viewerName, "swf"); _makepath_s(tplJsPath, 1024, dleDrive, dlePath, "AwayExtensions3dsMax\\AWDHTMLViewer\\swfobject", "js"); // Assemble paths for outputs _makepath_s(outHtmlPath, 1024, awdDrive, awdPath, awdName, "html"); _makepath_s(outSwfPath, 1024, awdDrive, awdPath, "viewer", "swf"); _makepath_s(outJsPath, 1024, awdDrive, awdPath, "swfobject", "js"); // Copy HTML, and evaluate any variables in the template CopyViewerHTML(tplHtmlPath, outHtmlPath, awdName); // Copy SWF and JS files as-is TCHAR * tplSwfPath_tchar=A2W(tplSwfPath); TCHAR * outSwfPath_tchar=A2W(outSwfPath); TCHAR * tplJsPath_tchar=A2W(tplJsPath); TCHAR * outJsPath_tchar=A2W(outJsPath); CopyFile(tplSwfPath_tchar, outSwfPath_tchar, false); CopyFile(tplJsPath_tchar, outJsPath_tchar, true); TCHAR * outHtmlPath_tchar=A2W(outHtmlPath); ShellExecute(NULL, _T("open"), outHtmlPath_tchar, NULL, NULL, SW_SHOWNORMAL); free (tplSwfPath_tchar); free (outSwfPath_tchar); free (tplJsPath_tchar); free (outJsPath_tchar); free (dleFullPath_ptr); free (outHtmlPath_tchar); }
std::string FileUtils::dirname(const char* path) { #ifdef PLATFORM_UNIX char* pathCopy = strdup(path); std::string dirname = ::dirname(pathCopy); free(pathCopy); return dirname; #else char drive[3]; char dir[MAX_PATH]; _splitpath_s(path, drive, /* drive */ 3, /* drive length */ dir, MAX_PATH, /* dir length */ 0, /* filename */ 0, /* filename length */ 0, /* extension */ 0 /* extension length */ ); std::string result; if (drive[0]) { result += std::string(drive); } result += dir; return result; #endif }
void RApplication::writeVideo() { char drive[_MAX_DRIVE]; char dir[_MAX_DIR]; char fname[_MAX_FNAME]; char ext[_MAX_EXT]; _splitpath_s( Pubvar::videoPath.c_str(), drive, dir, fname, ext); string outputPath = ""; int start = 0, end = 0, idx = 0, winsize = 8 * fps; VideoWriter writer; VideoCapture capCut; CV_Assert(capCut.open(Pubvar::videoPath)); Mat cutFrame; for (int i = winsize; i < videoLen; ++i) { if(fidOI[i]) { outputPath = "data/" + (string)fname + "_" + to_string(idx++) + ext; writer = VideoWriter(outputPath, CV_FOURCC('D', 'I', 'V', '3') , fps, frame.size()); capCut.set(CV_CAP_PROP_POS_FRAMES, i-winsize); for(int j=i-winsize ; j<=i ; j++) { capCut >> cutFrame; writer << cutFrame; } writer.release(); } } }
CNetwork::CNetwork(const CString &input_traf_file_name) : CObject() , m_network_name("") , m_traf_input_file(input_traf_file_name) , m_sensors_output_file("") , m_out_type(NO) , m_link_list() , m_node_list() , m_tp_lengths() { char buff[DTTMSZ]; char path_buffer[_MAX_PATH]; char drive[_MAX_DRIVE]; char dir[_MAX_DIR]; char base_name[_MAX_FNAME]; errno_t err; err = _splitpath_s(m_traf_input_file, drive, _MAX_DRIVE, dir, _MAX_DIR, base_name, _MAX_FNAME, NULL, NULL); if (err != 0) { printf("Error splitting the path. Error code %d.\n", err); exit(1); } err = _makepath_s(path_buffer, _MAX_PATH, drive, dir, base_name, NULL); if (err != 0) { printf("Error creating path. Error code %d.\n", err); exit(1); } m_sensors_output_file = path_buffer; m_sensors_output_file += _T(getDateTime(buff)); m_sensors_cum_output_file = m_sensors_output_file; }
void __IoInit() { INFO_LOG(HLE, "Starting up I/O..."); #ifdef _WIN32 char path_buffer[_MAX_PATH], drive[_MAX_DRIVE] ,dir[_MAX_DIR], file[_MAX_FNAME], ext[_MAX_EXT]; char mypath[_MAX_PATH]; GetModuleFileName(NULL,path_buffer,sizeof(path_buffer)); char *winpos = strstr(path_buffer, "Windows"); if (winpos) *winpos = 0; strcat(path_buffer, "dummy.txt"); _splitpath_s(path_buffer, drive, dir, file, ext ); // Mount a couple of filesystems sprintf(mypath, "%s%sMemStick\\", drive, dir); #else // TODO char mypath[256] = "/mount/sdcard/memstick"; #endif DirectoryFileSystem *memstick; memstick = new DirectoryFileSystem(&pspFileSystem, mypath); pspFileSystem.Mount("ms0:", memstick); pspFileSystem.Mount("fatms0:", memstick); pspFileSystem.Mount("fatms:", memstick); pspFileSystem.Mount("flash0:", new EmptyFileSystem()); pspFileSystem.Mount("flash1:", new EmptyFileSystem()); }
void GetSysDirectories(std::string &memstickpath, std::string &flash0path) { #ifdef _WIN32 wchar_t path_buffer[_MAX_PATH]; char drive[_MAX_DRIVE] ,dir[_MAX_DIR], file[_MAX_FNAME], ext[_MAX_EXT]; char memstickpath_buf[_MAX_PATH]; char flash0path_buf[_MAX_PATH]; GetModuleFileName(NULL, path_buffer, sizeof(path_buffer)); std::string path = ConvertWStringToUTF8(path_buffer); _splitpath_s(path.c_str(), drive, dir, file, ext ); // Mount a couple of filesystems sprintf(memstickpath_buf, "%s%smemstick\\", drive, dir); sprintf(flash0path_buf, "%s%sflash0\\", drive, dir); memstickpath = memstickpath_buf; flash0path = flash0path_buf; #else // TODO memstickpath = g_Config.memCardDirectory; flash0path = g_Config.flashDirectory; #endif }
/**************************************************************************************** TASK: Add a file to the hidden directory PRE : source - source of the file to add POST: File has been added to hidden directory ****************************************************************************************/ void BioModel::addFile(QString source) { char drive[_MAX_DRIVE]; char dir[_MAX_DIR]; char fname[_MAX_FNAME]; char ext[_MAX_EXT]; _splitpath_s(source.toStdString().c_str(), drive, dir, fname, ext); std::string outputDirectory = getCurrDirectory() + "\\bioguised-testfolder"; if(CreateDirectoryA(outputDirectory.c_str(), NULL) || ERROR_ALREADY_EXISTS == GetLastError()){ std::stringstream stringStream; stringStream << outputDirectory << "\\" << fname << ext; std::string newFileLocation = stringStream.str(); LPCSTR destination = newFileLocation.c_str(); BOOL successful = MoveFileA(source.toStdString().c_str(), destination); if(!successful){ GetLastError(); } else { printf("Success!!!!!!!!"); } } else { printf("Destination File does not exist"); } }
char * tr_sys_path_dirname (const char * path, tr_error ** error) { char drive[_MAX_DRIVE], dir[_MAX_DIR]; assert (path != NULL); /* TODO: Error handling */ if (_splitpath_s (path, drive, sizeof (drive), dir, sizeof (dir), NULL, 0, NULL, 0) == 0 && (*drive != '\0' || *dir != '\0')) { const size_t tmp_len = strlen (drive) + strlen (dir) + 2; char * const tmp = tr_new (char, tmp_len); if (_makepath_s (tmp, tmp_len, drive, dir, NULL, NULL) == 0) { size_t len = strlen(tmp); while (len > 0 && (tmp[len - 1] == '/' || tmp[len - 1] == '\\')) tmp[--len] = '\0'; return tmp; } tr_free (tmp); } return tr_strdup ("."); }
void GetSysDirectories(std::string &memstickpath, std::string &flash0path) { #ifdef _WIN32 char path_buffer[_MAX_PATH], drive[_MAX_DRIVE] ,dir[_MAX_DIR], file[_MAX_FNAME], ext[_MAX_EXT]; char memstickpath_buf[_MAX_PATH]; char flash0path_buf[_MAX_PATH]; GetModuleFileName(NULL,path_buffer,sizeof(path_buffer)); char *winpos = strstr(path_buffer, "Windows"); if (winpos) *winpos = 0; strcat(path_buffer, "dummy.txt"); _splitpath_s(path_buffer, drive, dir, file, ext ); // Mount a couple of filesystems sprintf(memstickpath_buf, "%s%smemstick\\", drive, dir); sprintf(flash0path_buf, "%s%sflash0\\", drive, dir); memstickpath = memstickpath_buf; flash0path = flash0path_buf; #else // TODO memstickpath = g_Config.memCardDirectory; flash0path = g_Config.flashDirectory; #endif }
void Setup(bool overwrite, bool overwriteAll) { static bool isSetup=false; if (isSetup && overwrite==false) return; isSetup=true; //Run at most once. vector<pair<string, bool> > toInstall; for(int k=0;k<setup::nFiles;k++) { toInstall.push_back(make_pair(string(setup::fileList[k]), overwriteAll)); } char dir[260]; GetCurrentDirectory(260, dir); vector<string> dyn; expandDirectory(dir, "*.lxml", dyn); expandDirectory(dir, "*.listdef", dyn); expandDirectory(dir, "*.meos", dyn); for (size_t k = 0; k < dyn.size(); k++) toInstall.push_back(make_pair(dyn[k], true)); char bf[260]; for(size_t k=0; k<toInstall.size(); k++) { const string src = toInstall[k].first.c_str(); char filename[128]; char ext[32]; _splitpath_s(src.c_str(), NULL, 0, NULL,0, filename, 128, ext, 32); string fullFile = string(filename) + ext; getUserFile(bf, fullFile.c_str()); bool canOverwrite = overwrite && toInstall[k].second; CopyFile(toInstall[k].first.c_str(), bf, !canOverwrite); } }
int file__make_dir_if_needed(const char *dir_) { char drive[path_len]; char dir[path_len]; char file[path_len]; char ext[path_len]; _splitpath_s(dir_, drive, path_len, dir, path_len, file, path_len, ext, path_len); // Drop drive's trailing slash. if (strlen(drive)) drive[strlen(drive) - 1] = '\0'; // _splitpath_s incorrectly assumes the last path component is a file; add it back. strncat(dir, file, path_len); strncat(dir, ext, path_len); char path[path_len]; strncpy(path, drive, path_len); bit success = true; char *token; char *dir_ptr = dir; while ((token = strsep(&dir_ptr, "\\"))) { if (strlen(token) == 0) continue; if (strlen(path)) strncat(path, "\\", path_len); strncat(path, token, path_len); if (!file__exists(path)) success = success && CreateDirectory(path, NULL); } return success; }
HRESULT CShellExt::Initialize(LPCITEMIDLIST pidlFolder, LPDATAOBJECT pDataObj, HKEY hProgID) { memset(_vc_path, 0, MAX_PATH*2); char inifile[MAX_PATH] = {0}; char drive[_MAX_DRIVE*2] = {0}; char dir[_MAX_DIR*2] = {0}; GetModuleFileNameA(g_hInstance, inifile, MAX_PATH); //MessageBoxA(NULL, inifile, "", MB_OK); errno_t err; err = _splitpath_s(inifile, drive, _MAX_DRIVE, dir, _MAX_DIR, NULL, 0, NULL, 0); err = _makepath_s(inifile, _MAX_PATH, drive, dir, "zShellExt", "ini"); GetPrivateProfileStringA("VS2008", "path", "", _vc_path, MAX_PATH*2, inifile); //MessageBoxA(NULL, _vc_path, "", MB_OK); return S_OK; }
char *get_app_dir() { char *path = NULL, *dir = NULL; #ifdef _WIN32 char drive_buf[_MAX_DRIVE], dir_buf[_MAX_DIR]; if ((path = get_exec_path()) == NULL) goto end; if(_splitpath_s(path, drive_buf, _MAX_DRIVE, dir_buf, _MAX_DIR, NULL, 0, NULL, 0) != 0) { perror("get_app_dir"); goto end; } if ((dir = _strdup(dir_buf)) == NULL) { perror("get_app_dir"); goto end; } #else char *buf = NULL; if ((path = get_exec_path()) == NULL) goto end; /* dirname returns a pointer to internal storage space allocated on the first call */ if ((buf = dirname(path)) == NULL) { perror("get_app_dir"); goto end; } if ((dir = strdup(buf)) == NULL) { perror("get_app_dir"); goto end; } #endif end: free(path); return dir; }
BOOL SendFile(LPCSTR lpszSubject, LPCSTR lpszTo, LPCSTR lpszName, LPCSTR lpszText, LPCSTR lpszFullFileName) { HINSTANCE hMAPI = ::LoadLibrary("mapi32.dll"); if (!hMAPI) return FALSE; LPMAPISENDMAIL lpfnMAPISendMail = (LPMAPISENDMAIL)::GetProcAddress(hMAPI, "MAPISendMail"); char szDrive[_MAX_DRIVE] = {0}; char szDir[_MAX_DIR] = {0}; char szName[_MAX_FNAME] = {0}; char szExt[_MAX_EXT] = {0}; _splitpath_s(lpszFullFileName, szDrive, szDir, szName, szExt); char szFileName[MAX_PATH] = {0}; strcat_s(szFileName, szName); strcat_s(szFileName, szExt); char szFullFileName[MAX_PATH] = {0}; strcat_s(szFullFileName, lpszFullFileName); MapiFileDesc MAPIfile = {0}; ZeroMemory(&MAPIfile, sizeof(MapiFileDesc)); MAPIfile.nPosition = 0xFFFFFFFF; MAPIfile.lpszPathName = szFullFileName; MAPIfile.lpszFileName = szFileName; char szTo[MAX_PATH] = {0}; strcat_s(szTo, lpszTo); char szNameTo[MAX_PATH] = {0}; strcat_s(szNameTo, lpszName); MapiRecipDesc recipient = {0}; recipient.ulRecipClass = MAPI_TO; recipient.lpszAddress = szTo; recipient.lpszName = szNameTo; char szSubject[MAX_PATH] = {0}; strcat_s(szSubject, lpszSubject); char szText[MAX_PATH] = {0}; strcat_s(szText, lpszText); MapiMessage MAPImsg = {0}; MAPImsg.lpszSubject = szSubject; MAPImsg.lpRecips = &recipient; MAPImsg.nRecipCount = 1; MAPImsg.lpszNoteText = szText; MAPImsg.nFileCount = 1; MAPImsg.lpFiles = &MAPIfile; ULONG nSent = lpfnMAPISendMail(0, 0, &MAPImsg, 0, 0); FreeLibrary(hMAPI); return (nSent == SUCCESS_SUCCESS || nSent == MAPI_E_USER_ABORT); }
FilePath::FilePath( char const *c ) { String s( c ); for( char &ch : s ) ch = tolower( ch ); std::replace( s.begin(), s.end(), '\\', '/' ); _splitpath_s( s, m_drive, m_drive.MaxLength(), m_directory, m_directory.MaxLength(), m_fileName, m_fileName.MaxLength(), m_extension, m_extension.MaxLength() ); m_fullPath = m_drive + m_directory + m_fileName + m_extension; }
//去掉绝对路径中的文件名与扩展名,szPath需要分配空间 BOOL GetFilePathA(const char* szFullPath, char* szPath) { char szDrive[_MAX_DRIVE]; char szDir[_MAX_DIR]; _splitpath_s(szFullPath, szDrive, _MAX_DRIVE, szDir, _MAX_DIR, NULL, NULL, NULL, NULL); _makepath_s(szPath, MAX_PATH, szDrive, szDir, NULL, NULL); return TRUE; }
void TpresetsPage::onSaveToFile(void) { int i=lvGetSelItem(IDC_LV_PRESETS); char_t presetFlnm[MAX_PATH]; _splitpath_s((*parent->localPresets)[i]->presetName, NULL, 0, NULL, 0, presetFlnm, countof(presetFlnm), NULL, 0); if (dlgGetFile(true,m_hwnd,_(-IDD_PRESETS,_l("Save ffdshow preset")),presetfilter,presetext,presetFlnm,_l("."),0)) { (*parent->localPresets)[i]->saveFile(presetFlnm); } }
string CLogger::GetAppPathA() { char szFilePath[MAX_PATH] = { 0 }, szDrive[MAX_PATH] = { 0 }, szDir[MAX_PATH] = { 0 }, szFileName[MAX_PATH] = { 0 }, szExt[MAX_PATH] = { 0 }; GetModuleFileNameA(NULL, szFilePath, sizeof(szFilePath)); _splitpath_s(szFilePath, szDrive, szDir, szFileName, szExt); string str(szDrive); str.append(szDir); return str; }
void _bmpImage::setSourceFile(char *path) { _splitpath_s(path, drive, dir, fname, ext ); workingDir = drive; workingDir += dir; workingDir += fname; sourceFile = path; }
std::string getProcessName() { TCHAR pathName[MAX_PATH]; GetModuleFileName(NULL, pathName, MAX_PATH); TCHAR fileName[MAX_PATH]; _splitpath_s(pathName, NULL, 0, NULL, 0, fileName, MAX_PATH, NULL, 0); return std::string(fileName); }
int KGTestMapDisuseResource::FindResource(const char cszResourceName[] , set<string>& setResList) { int nRetCode = false; int nResult = false; char szName[MAX_PATH]; char szExt[MAX_PATH]; std::pair<std::set<string>::iterator,bool> retInsert; KG_ASSERT_EXIT(cszResourceName); KG_PROCESS_ERROR(cszResourceName[0] != '\0'); nRetCode = strncpy_s(szName, sizeof(szName), cszResourceName, strlen(cszResourceName)); KGLOG_PROCESS_ERROR(nRetCode == 0); nRetCode = _mbslwr_s((unsigned char*)szName, sizeof(szName));//筞 KGLOG_PROCESS_ERROR(nRetCode == 0); retInsert = setResList.insert(szName); KG_PROCESS_SUCCESS(!retInsert.second); //插入失败表示有重复,不做接下来的解析 nRetCode = _splitpath_s(szName, NULL, 0, NULL, 0, NULL, 0, szExt, sizeof(szExt)); KGLOG_PROCESS_ERROR(nRetCode == 0); if (strncmp(szExt, ".modelset", sizeof(".modelset")) == 0) { nRetCode = FindResInModelset(szName, setResList); KGLOG_PROCESS_ERROR(nRetCode); } if (strncmp(szExt, ".pvs", sizeof(".pvs")) == 0) { nRetCode = FindResInPVS(szName, setResList); KGLOG_PROCESS_ERROR(nRetCode); } if (strncmp(szExt, ".stree", sizeof(".stree")) == 0) { nRetCode = FindResInSTree(szName, setResList); KGLOG_PROCESS_ERROR(nRetCode); } if (strncmp(szExt, ".mdl", sizeof(".mdl")) == 0) { nRetCode = FindResInMDL(cszResourceName, setResList); KGLOG_PROCESS_ERROR(nRetCode); } if (strncmp(szExt, ".sfx", sizeof(".sfx")) == 0) { nRetCode = FindResInSFX(cszResourceName, setResList); KGLOG_PROCESS_ERROR(nRetCode); } Exit1: nResult = true; Exit0: return nResult; }
void ImageLoad (IMG img, void *context) { fprintf (stderr, "Notified of load of %s at [%p,%p]\n", IMG_Name(img).c_str(), (char *)IMG_LowAddress(img), (char *)IMG_HighAddress(img)); // See if this is ntdll.dll char szName[_MAX_FNAME]; char szExt[_MAX_EXT]; _splitpath_s (IMG_Name(img).c_str(), NULL, 0, NULL, 0, szName, _MAX_FNAME, szExt, _MAX_EXT); strcat_s (szName, _MAX_FNAME, szExt); if (0 != _stricmp ("ntdll.dll", szName)) return; RTN rtn = RTN_FindByName (img, "RtlAllocateHeap"); if (RTN_Invalid() == rtn) { fprintf (stderr, "Failed to find RtlAllocateHeap in %s\n", IMG_Name(img).c_str()); return; } fprintf(stderr,"Replacing\n"); PROTO protoRtlAllocateHeap = PROTO_Allocate (PIN_PARG(void *), CALLINGSTD_STDCALL, "RtlAllocateHeap", PIN_PARG(WINDOWS::PVOID), // HeapHandle PIN_PARG(WINDOWS::ULONG), // Flags PIN_PARG(WINDOWS::SIZE_T), // Size PIN_PARG_END()); RTN_ReplaceSignature (rtn, (AFUNPTR)replacement_RtlAllocateHeap, IARG_PROTOTYPE, protoRtlAllocateHeap, IARG_ORIG_FUNCPTR, IARG_FUNCARG_ENTRYPOINT_VALUE, 0, IARG_FUNCARG_ENTRYPOINT_VALUE, 1, IARG_FUNCARG_ENTRYPOINT_VALUE, 2, IARG_CONTEXT, IARG_END); PROTO_Free (protoRtlAllocateHeap); }
void TautoPresetProps::getVolume(void) { const char_t *flnm=deci->getSourceName(); char_t dsk[MAX_PATH]; _splitpath_s(flnm,dsk,MAX_PATH,NULL,0,NULL,0,NULL,0); DWORD serial,maximumComponentLength,volumeFlags; ffstring disk(dsk); disk += _l("\\"); wasVolume=GetVolumeInformation(disk.c_str(),volumeName,256,&serial,&maximumComponentLength,&volumeFlags,NULL,0); if (wasVolume) { tsnprintf_s(volumeSerial, countof(volumeSerial), _TRUNCATE, _l("%X-%X"),(int)HIWORD(serial),(int)LOWORD(serial)); } }
//Helper function for sayHi(): strips a full path of the directory prefix. //Input: character array of the directory path + filename //Output: a string containing the filename std::string TextBuddy::getFilenameFromPath(char* argv){ char drive[_MAX_DRIVE]; char dir[_MAX_DIR]; char fname[_MAX_FNAME]; char ext[_MAX_EXT]; _splitpath_s(argv, drive, dir, fname, ext); std::stringstream ss; ss << fname << ext; std::string filename = ""; ss >> filename; return filename; }
void OutputError(bool _b, LPCWSTR _text, const char* _file, int _line){ #ifdef _DEBUG if (_b == false){ WCHAR fileName[64], str[256]; char file[64], ext[8]; _splitpath_s(_file, nullptr, 0, nullptr, 0, file, 64, ext, 8); strcat_s(file, ext); Utility::ConvertToWChar(fileName, file); wsprintf(str, L"%s:%d行目からのエラー ", fileName, _line); MessageBox(NULL, _text, str, MB_OK); } #endif }
char *oscap_dirname(char *path) { if (path == NULL || *path == '\0' || (strchr(path, '/') == NULL && strchr(path, '\\') == NULL)) { return strdup("."); } char dir[_MAX_DIR]; char drive[_MAX_DRIVE]; char dirname[_MAX_PATH]; _splitpath_s(path, drive, _MAX_DRIVE, dir, _MAX_DIR, NULL, 0, NULL, 0); _makepath_s(dirname, _MAX_PATH, drive, dir, NULL, NULL); oscap_rtrim(dirname, '/'); oscap_rtrim(dirname, '\\'); return oscap_strdup(dirname); }
int fullsplit( const char* path ) { #ifdef _WIN32 // FIXME: 2008 Upgrades needed here? #if defined( _MSC_VER ) && ( _MSC_VER <= 1310 ) // up to VS2003 _splitpath( path, temp_drive, temp_dir, temp_fname, temp_ext ); #else // VS2005 using MS STL, boooooo _splitpath_s( path, temp_drive, MAXDRIVE, temp_dir, MAXDIR, temp_fname, MAXFILE, temp_ext, MAXEXT ); #endif return 0; #else return fnsplit( path, temp_drive, temp_dir, temp_fname, temp_ext ); #endif }
bool CIni::SetPath(const char* lpFilename) { char IniPath[_MAX_PATH] = ""; char Buf[_MAX_PATH], Path[_MAX_PATH]; char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT]; GetModuleFileName(AfxGetApp()->m_hInstance, Buf, _MAX_PATH); _splitpath_s(Buf, drive, _MAX_DRIVE, dir, _MAX_DIR, fname, _MAX_FNAME, ext, _MAX_EXT); strcpy_s(Path, _MAX_PATH, drive); strcat_s(Path, _MAX_PATH, dir); strcpy_s(IniPath, _MAX_PATH, Path); wsprintf(IniPath, "%s%s", IniPath, lpFilename); strcpy_s(m_szFileName, _MAX_PATH, IniPath); return true; }
void timed_trace(const char* function_name, const char* full_path, int line, const char* action) { char filename[_MAX_FNAME]; _splitpath_s(full_path, NULL, 0, NULL, 0, filename, _MAX_FNAME, NULL, 0); // Time: std::cout << global_tm.timer.time() << ": " // File:Line << filename << ":" << line << " - " // function_name, action << function_name << ", " << action << std::endl; };
std::string GetExeDir() { char strFullPath[MAX_PATH] = { 0 } ; ::GetModuleFileNameA( NULL, strFullPath, _MAX_PATH ); char strDrive[MAX_PATH] = {0}; char strDir[MAX_PATH] = {0}; _splitpath_s( strFullPath, strDrive, MAX_PATH, strDir, MAX_PATH, NULL, 0, NULL, 0 ); const std::string result = std::string( strDrive ) + strDir; TRACE1("Here is where CAB files will be created [%s]\n", result.c_str()); return result; }