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; }
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; }
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 ("."); }
//去掉绝对路径中的文件名与扩展名,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 TquantTablesPageBase::create(HWND parent) { createDialog(dialogId,parent); SetParent(m_hwnd,parent); setPos(0,0); show(true); matrixflnm[0]='\0'; _makepath_s(matrixdir,MAX_PATH,NULL,config->pth,_l("custom matrices"),NULL); firstdir=true; }
static void fixRelativePaths(strings &dirs, const char_t *basepath) { for (strings::iterator d = dirs.begin(); d != dirs.end(); d++) if (PathIsRelative(d->c_str())) { char_t absdir[MAX_PATH]; _makepath_s(absdir, countof(absdir), NULL, basepath, d->c_str(), NULL); char_t absdirC[MAX_PATH]; PathCanonicalize(absdirC, absdir); *d = absdirC; } }
void TsubtitlesFile::findPossibleSubtitles(const char_t *dir, strings &files) { char_t autosubmask[MAX_PATH]; _makepath_s(autosubmask, MAX_PATH, NULL, dir,/*name*/_l("*"), _l("*")); strings files0; findFiles(autosubmask, files0); for (strings::iterator f = files0.begin(); f != files0.end(); f++) if (extMatch(f->c_str())) { files.push_back(*f); } std::sort(files.begin(), files.end(), ffstring_iless()); }
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); }
char* fullmerge( char* path ) { #ifdef _WIN32 // FIXME: 2008 Upgrades needed here? #if defined( _MSC_VER ) && ( _MSC_VER <= 1310 ) // up to VS2003 _makepath( path, temp_drive, temp_dir, temp_fname, temp_ext ); #else // VS2005 using MS STL, booooo _makepath_s( path, MAXPATH, temp_drive, temp_dir, temp_fname, temp_ext ); #endif #else fnmerge( path, temp_drive, temp_dir, temp_fname, temp_ext ); #endif return path; }
Path getApplicationDirectory() { string result; string l_drive; string l_directory; char l_path[MAX_PATH]; splitApplicationPath( &l_drive, &l_directory, NULL, NULL ); _makepath_s( l_path, l_drive.c_str(), l_directory.c_str(), NULL, NULL ); PathAddBackslashA( l_path ); result = reinterpret_cast<char*>(l_path); return Path(result); }
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 DirectoryContaining(const std::string &filename) { // This code isn't tested but I believe it should work. Might need to add // some const_casts to make it compile though. char drive[_MAX_DRIVE]; char dir[_MAX_DIR]; char ext[_MAX_EXT]; errno_t err = _splitpath_s(filename.c_str(), drive, _MAX_DRIVE, dir, _MAX_DIR, nullptr, 0, ext, _MAX_EXT); if (err == 0) { char fullDir[_MAX_PATH]; err = _makepath_s(fullDir, _MAX_PATH, drive, dir, nullptr, nullptr); if (err == 0) return std::string(fullDir); } return filename; }
//============================== Twinamp2 ==================================== Twinamp2::Twinamp2(const char_t *Iwinampdir) { ff_strncpy(winampdir, Iwinampdir, countof(winampdir)); strings files; char_t mask[MAX_PATH]; _makepath_s(mask, MAX_PATH, NULL, winampdir, _l("plugins\\dsp*"), _l("dll")); findFiles(mask, files); for (strings::const_iterator flnm = files.begin(); flnm != files.end(); flnm++) { DPRINTF(_l("Loading Winamp DSP plugin %s"), flnm->c_str()); Twinamp2dspDll *dsp = new Twinamp2dspDll(*flnm); if (!dsp->filters.empty()) { dsps.push_back(dsp); } else { delete dsp; } } }
//=========================== Twinamp2dspDll ================================= Twinamp2dspDll::Twinamp2dspDll(const ffstring &flnm): refcount(1) { dll = NULL; winampDSPGetHeaderType = NULL; hdr = NULL; char_t filename[MAX_PATH], name[MAX_PATH], ext[MAX_PATH]; _splitpath_s(flnm.c_str(), NULL, 0, NULL, 0, name, MAX_PATH, ext, MAX_PATH); _makepath_s(filename, MAX_PATH, NULL, NULL, name, ext); // DSP stacker, Adapt-X and Vst host are not compatible with ffdshow currently. Maybe ffdshow's bug, but I can't help... if (_strnicmp(_l("dsp_stacker.dll"), filename, 16) == 0 || _strnicmp(_l("dsp_adaptx.dll"), filename, 15) == 0 || _strnicmp(_l("dsp_sps.dll"), filename, 11) == 0 ) { return; } dll = new Tdll(flnm.c_str(), NULL); if (dll->ok) { dll->loadFunction(winampDSPGetHeaderType, "winampDSPGetHeader2"); if (!dll->ok) { // retry with index 1. dll->ok = true; dll->loadFunctionByIndex(winampDSPGetHeaderType, 1); } } if (dll->ok) { hdr = winampDSPGetHeaderType(); if (hdr->version != DSP_HDRVER) { hdr = NULL; return; } descr = hdr->description; dllFileName = filename; } if (hdr) for (int i = 0;; i++) { winampDSPModule *flt = hdr->getModule(i); if (!flt) { break; } flt->hDllInstance = dll->hdll; filters.push_back(new Twinamp2dsp(this, flt)); } }
void TffdshowPageBase::onHelp(void) { if (!page || !page->helpURL) { return; } char_t fullflnm[MAX_PATH]; bool internet = false; if (strlen(page->helpURL) > 6 && strncmp(page->helpURL, _l("http"), 4) == 0) { internet = true; const char_t *translatedURL = _(-1, page->helpURL); ff_strncpy(fullflnm, translatedURL, countof(fullflnm)); } else { _makepath_s(fullflnm, MAX_PATH, NULL, config->pth, _l("help\\"), NULL); strncat_s(fullflnm, countof(fullflnm), page->helpURL, _TRUNCATE); } if (internet || fileexists(fullflnm)) { ShellExecute(m_hwnd, _l("open"), fullflnm, NULL, _l("."), SW_SHOWNORMAL); } }
char * tr_sys_path_basename (const char * path, tr_error ** error) { char fname[_MAX_FNAME], ext[_MAX_EXT]; assert (path != NULL); /* TODO: Error handling */ if (_splitpath_s (path, NULL, 0, NULL, 0, fname, sizeof (fname), ext, sizeof (ext)) == 0 && (*fname != '\0' || *ext != '\0')) { const size_t tmp_len = strlen (fname) + strlen (ext) + 2; char * const tmp = tr_new (char, tmp_len); if (_makepath_s (tmp, tmp_len, NULL, NULL, fname, ext) == 0) return tmp; tr_free (tmp); } return tr_strdup ("."); }
void GetBinaryPathWithFileNameA(char *path, const size_t buffer_size, const char* filename) { char fullpath[_MAX_PATH]; char drive[_MAX_DRIVE]; char dir[_MAX_DIR]; char modulename[_MAX_PATH]; PlatformAgnostic::SystemInfo::GetBinaryLocation(modulename, _MAX_PATH); _splitpath_s(modulename, drive, _MAX_DRIVE, dir, _MAX_DIR, nullptr, 0, nullptr, 0); _makepath_s(fullpath, drive, dir, filename, nullptr); size_t len = strlen(fullpath); if (len < buffer_size) { memcpy(path, fullpath, len * sizeof(char)); } else { len = 0; } path[len] = char(0); }
void CCEFView::OnInitialUpdate() { CView::OnInitialUpdate(); CefRefPtr<ClientHandler> client(new ClientHandler()); m_clientHandler = client; CefWindowInfo info; RECT rect; GetClientRect(&rect); info.SetAsChild(GetSafeHwnd(), rect); CefBrowserSettings browserSettings; browserSettings.web_security_disabled = true; char path_buffer[_MAX_PATH]; char drive[_MAX_DRIVE]; char dir[_MAX_DIR]; char fname[_MAX_FNAME]; char ext[_MAX_EXT]; errno_t err; GetModuleFileNameA(NULL, path_buffer, sizeof(path_buffer)); err = _splitpath_s(path_buffer, drive, _MAX_DRIVE, dir, _MAX_DIR, fname, _MAX_FNAME, ext, _MAX_EXT); if (err != 0) { //TODO: Add Error Handler } std::string s = dir; s += "html"; err = _makepath_s(path_buffer, _MAX_PATH, drive, s.c_str(), "index", "html"); if (err != 0) { //TODO: Add Error Handler } CefBrowser::CreateBrowser(info, static_cast<CefRefPtr<CefClient> >(client), path_buffer, browserSettings); // TODO: Add your specialized code here and/or call the base class }
bool CmbFileFind::FindFile(CString path) { char drive[_MAX_DRIVE]; char dir[_MAX_DIR]; char fname[_MAX_FNAME]; char ext[_MAX_EXT]; const TCHAR* cstr = (LPCTSTR)path; _splitpath_s(cstr, (char *)drive, _MAX_DRIVE, (char *)dir, _MAX_DIR, (char *)fname, _MAX_FNAME, (char *)ext, _MAX_EXT); char root[MAX_PATH]; _makepath_s(root, sizeof(root), drive, dir, 0, 0); m_rootPath = root; if (m_nextInfo) { delete m_nextInfo; } m_nextInfo = new WIN32_FIND_DATA; m_fileListHandle = ::FindFirstFile(path, m_nextInfo); return m_fileListHandle != INVALID_HANDLE_VALUE; }
void TdeinterlacePage::fillDeinterlacers(void) { int ii = cbxGetCurSel(IDC_CBX_DEINT_METHOD); cbxClear(IDC_CBX_DEINT_METHOD); int i; for (i = 0; TdeinterlaceSettings::methodProps[i].name; i++) if (!(TdeinterlaceSettings::methodProps[i].id == TdeinterlaceSettings::FRAMERATEDOUBLER && !(Tconfig::cpu_flags & FF_CPU_MMXEXT)) && TdeinterlaceSettings::methodProps[i].id != TdeinterlaceSettings::DSCALER) { cbxAdd(IDC_CBX_DEINT_METHOD, _(IDC_CBX_DEINT_METHOD, TdeinterlaceSettings::methodProps[i].name), TdeinterlaceSettings::methodProps[i].cfgId); } const char_t *dscalerDir = cfgGetStr(IDFF_dscalerPath); if (!dscalerDir || !dscalerDir[0]) { dscalerstart = 0; return; } char_t dsmask[MAX_PATH]; _makepath_s(dsmask, MAX_PATH, NULL, dscalerDir, _l("DI_*"), _l("dll")); strings dis; findFiles(dsmask, dis, true); dscalerstart = i - 1; diflnms.clear(); for (strings::const_iterator di = dis.begin(); di != dis.end(); di++) { char_t flnm[MAX_PATH]; extractfilename(di->c_str(), flnm); if (stricmp(flnm, _l("DI_Adaptive.dll")) != 0) { char_t diname[256]; Tdscaler_DI didll(di->c_str(), deci, true); if (didll.fm) { tsnprintf_s(diname, countof(diname), _TRUNCATE, _l("DScaler: %s"), (const char_t*)text<char_t>(didll.fm->szName)); cbxAdd(IDC_CBX_DEINT_METHOD, diname, 9); diflnms.push_back(*di); } } } cbxSetCurSel(IDC_CBX_DEINT_METHOD, ii); }
void FilePath::SetDirectory( String const &directory ) { m_directory = directory; _makepath_s( m_fullPath, m_fullPath.MaxLength(), m_drive, m_directory, m_fileName, m_extension ); }
void TsubtitlesFile::findSubtitlesFile(const char_t *aviFlnm, const char_t *sdir, const char_t *sext, char_t *subFlnm, size_t buflen, int heuristic, IcheckSubtitle *checkSubtitle) { if (!subFlnm) { return; } if (heuristic) { char_t aviDsk[MAX_PATH], aviDir[MAX_PATH], aviName[MAX_PATH]; _splitpath_s(aviFlnm, aviDsk, countof(aviDsk), aviDir, countof(aviDir), aviName, countof(aviName), NULL, 0); char_t aviDskDirName[MAX_PATH]; _makepath_s(aviDskDirName, countof(aviDskDirName), aviDsk, aviDir, aviName, NULL); strings subfiles; findPossibleSubtitles(aviFlnm, sdir, subfiles); int mindist = INT_MAX; EditDistance dist; strings::const_iterator s = subfiles.end(); typedef std::vector< std::pair<int, ffstring> > TsubsDists; TsubsDists subdists; for (strings::const_iterator sf = subfiles.begin(); sf != subfiles.end(); sf++) { char_t sfDsk[MAX_PATH], sfDir[MAX_PATH], sfName[MAX_PATH]; _splitpath_s(sf->c_str(), sfDsk, countof(sfDsk), sfDir, countof(sfDir), sfName, countof(sfName), NULL, 0); char_t sfDskDirName[MAX_PATH]; _makepath_s(sfDskDirName, countof(sfDskDirName), sfDsk, sfDir, sfName, NULL); int newdist = dist.CalEditDistance(aviDskDirName, sfDskDirName, 2 * MAX_PATH); if (!checkSubtitle) { if (newdist < mindist) { s = sf; mindist = newdist; if (mindist == 0) { break; } } } else { subdists.push_back(std::make_pair(newdist, *sf)); } } if (!checkSubtitle) { if (s != subfiles.end()) { ff_strncpy(subFlnm, s->c_str(), buflen); return; } } else { std::stable_sort(subdists.begin(), subdists.end()); for (TsubsDists::const_iterator sd = subdists.begin(); sd != subdists.end(); sd++) if (checkSubtitle->checkSubtitle(sd->second.c_str())) { ff_strncpy(subFlnm, sd->second.c_str(), buflen); return; } } } else { char_t dsk[MAX_PATH], dir[MAX_PATH], name[MAX_PATH], ext[MAX_PATH]; _splitpath_s(aviFlnm, dsk, countof(dsk), dir, countof(dir), name, countof(name), ext, countof(ext)); char_t fname[MAX_PATH]; _makepath_s(fname, countof(fname), NULL, NULL, name, ext); //fname - movie file name with extension (without path) if (name[0]) { char_t path[MAX_PATH]; _makepath_s(path, countof(path), dsk, dir, NULL, NULL); //path - directory where movie is stored strings dirs; strtok(sdir, _l(";"), dirs); fixRelativePaths(dirs, path); //exact match (only extension differs) for (strings::const_iterator d = dirs.begin(); d != dirs.end(); d++) { if (d->empty()) { continue; } char_t subFlnm0[MAX_PATH]; //sub_extsfind(d->c_str(),name,subFlnm0); strings etensions; strtok(sext, _l(";"), etensions); for (strings::const_iterator e = etensions.begin(); e != etensions.end(); e++) { _makepath_s(subFlnm0, countof(subFlnm0), NULL, d->c_str(), name, e->c_str()); if (fileexists(subFlnm0) && (!checkSubtitle || checkSubtitle->checkSubtitle(subFlnm0))) { ff_strncpy(subFlnm, subFlnm0, buflen); return; } } } //movie.avi -> movie en.txt, movie.en.sub,.... for (strings::const_iterator d = dirs.begin(); d != dirs.end(); d++) { _makepath_s(fname, MAX_PATH, NULL, d->c_str(), name, NULL); strncat_s(fname, countof(fname), _l("*"), _TRUNCATE); //fname - c:\movies\movie*.* strings files; findFiles(fname, files); for (strings::const_iterator f = files.begin(); f != files.end(); f++) { ffstring ext; extractfileext(f->c_str(), ext); ext.ConvertToLowerCase(); strings etensions; strtok(sext, _l(";"), etensions); for (strings::const_iterator e = etensions.begin(); e != etensions.end(); e++) if (ext == *e && (!checkSubtitle || checkSubtitle->checkSubtitle(f->c_str()))) { ff_strncpy(subFlnm, f->c_str(), buflen); subFlnm[buflen - 1] = '\0'; return; } } } } } subFlnm[0] = '\0'; }
bool TopMenuCore::startup() { SetLastError(ERROR_SUCCESS); DWORD le; if(!m_hStopEvent) { note("could not create stop event"); return false; } char szLibPath[MAX_PATH]; if(!GetModuleFileName((HINSTANCE)&__ImageBase, szLibPath, MAX_PATH)) { le = GetLastError(); return false; } char szLibDrive[MAX_PATH]; char szLibDir[MAX_PATH]; char szLibFname[MAX_PATH]; char szLibExt[MAX_PATH]; _splitpath_s(szLibPath, szLibDrive, szLibDir, szLibFname, szLibExt); //lint !e534 JLD _makepath_s(szLibPath, szLibDrive, szLibDir, "*", "dll"); //lint !e534 JLD WIN32_FIND_DATA findData; HANDLE hSearch = FindFirstFile(szLibPath, &findData); if(hSearch) { do { char szPath[MAX_PATH]; _makepath_s(szPath, szLibDrive, szLibDir, findData.cFileName, ""); //lint !e534 JLD HMODULE hPluginMod = LoadLibrary(szPath); if(!hPluginMod) { le = GetLastError(); continue; } FARPROC createProc = GetProcAddress(hPluginMod, CREATE_PROC_NAME); if(!createProc) { le = GetLastError(); FreeLibrary(hPluginMod); //lint !e534 JLD continue; } FARPROC versionProc = GetProcAddress(hPluginMod, VERSION_PROC_NAME); if(!versionProc) { le = GetLastError(); FreeLibrary(hPluginMod); //lint !e534 JLD continue; } TopMenu_PluginStackEntry* pStackPtr = m_pTopEntry; while(pStackPtr) { if(pStackPtr->m_hModule == hPluginMod) { break; // module already in stack } } if(pStackPtr) { FreeLibrary(hPluginMod); //lint !e534 JLD continue; // plugin already loaded } VERSION_PROC& GetPluginVersion = (VERSION_PROC&)*versionProc; DWORD pluginVersion = GetPluginVersion(); if(pluginVersion < TopMenu_Plugin::GetPluginVersion()) { le = GetLastError(); FreeLibrary(hPluginMod); //lint !e534 JLD continue; } CREATE_PROC& CreatePlugin = (CREATE_PROC&)*createProc; TopMenu_Plugin* pPlugin = CreatePlugin(); if(!pPlugin) { le = GetLastError(); FreeLibrary(hPluginMod); //lint !e534 JLD continue; } TopMenu_PluginStackEntry* pPluginEntry = new TopMenu_PluginStackEntry(); pPluginEntry->m_hModule = hPluginMod; pPluginEntry->m_pPlugin = pPlugin; if(m_pTopEntry) { pPluginEntry->m_pNext = m_pTopEntry; } m_pTopEntry = pPluginEntry; } while(FindNextFile(hSearch, &findData)); FindClose(hSearch); //lint !e534 JLD hSearch = NULL; } return true; } //lint !e550 JLD
void TsubtitlesFile::findPossibleSubtitles(const char_t *aviFlnm, const char_t *sdir, strings &files, subtitleFilesSearchMode searchMode) { if (!aviFlnm || !sdir) { return; } char_t avidir[MAX_PATH]; if (aviFlnm[0]) { char_t dsk[MAX_PATH], dir[MAX_PATH], name[MAX_PATH]; _splitpath_s(aviFlnm, dsk, MAX_PATH, dir, MAX_PATH, name, MAX_PATH, NULL, 0); _makepath_s(avidir, countof(avidir), dsk, dir, NULL, NULL); } else { strcpy(avidir, _l(".")); } strings dirs; strtok(sdir, _l(";"), dirs); fixRelativePaths(dirs, avidir); for (strings::const_iterator sd = dirs.begin(); sd != dirs.end(); sd++) { findPossibleSubtitles(sd->c_str(), files); } // If search mode is "search video file match then heuristic", then test if at least 1 subtitle filename matches with the video filename bool videoFileMatch = false; ffstring videoFlnmNoExt; extractfilenameWOext(aviFlnm, videoFlnmNoExt); videoFlnmNoExt.ConvertToLowerCase(); if (searchMode == SUBFILES_VIDEO_FILE_HEURISTIC) { for (strings::iterator f = files.begin(); f != files.end(); f++) { ffstring flnmNoExt; extractfilenameWOext((*f).c_str(), flnmNoExt); flnmNoExt.ConvertToLowerCase(); if (strncmp(videoFlnmNoExt.c_str(), flnmNoExt.c_str(), videoFlnmNoExt.length()) == 0) { /* Common portion of video and subtitle filenames. Check if lengths are equal (identical names) or if this is a dot "." right after like in videofile.<suffix>.ext */ if (videoFlnmNoExt.length() == flnmNoExt.length() || flnmNoExt[videoFlnmNoExt.length()] == _l('.')) { videoFileMatch = true; break; } } } } if (searchMode != SUBFILES_ALL) { EditDistance dist; for (strings::iterator f = files.begin(); f != files.end();) { ffstring flnmNoExt; extractfilenameWOext((*f).c_str(), flnmNoExt); flnmNoExt.ConvertToLowerCase(); // If search mode is based on video file name removes the non matching entries if (searchMode == SUBFILES_VIDEO_FILE_MATCH || (searchMode == SUBFILES_VIDEO_FILE_HEURISTIC && videoFileMatch)) { if (strncmp(videoFlnmNoExt.c_str(), flnmNoExt.c_str(), videoFlnmNoExt.length()) != 0 || (videoFlnmNoExt.length() != flnmNoExt.length() && flnmNoExt[videoFlnmNoExt.length()] != _l('.'))) { f = files.erase(f); } else { f++; } continue; } // Heuristic search int distance = dist.CalEditDistance(videoFlnmNoExt.c_str(), flnmNoExt.c_str(), 2 * MAX_PATH); //DPRINTF(_l("Subtitle files : %s vs %s match result = %d"), flnmNoExt.c_str(), videoFlnmNoExt.c_str(), distance); if (distance > SUBFILES_HEURISTIC_LIMIT) { f = files.erase(f); } else { f++; } } } }
/*++ Function: _wmakepath See MSDN doc. --*/ void __cdecl _wmakepath( wchar_16 *path, const wchar_16 *drive, const wchar_16 *dir, const wchar_16 *fname, const wchar_16 *ext) { CHAR Dir[ _MAX_DIR ]={0}; CHAR FileName[ _MAX_FNAME ]={0}; CHAR Ext[ _MAX_EXT ]={0}; CHAR Path[ _MAX_PATH ]={0}; PERF_ENTRY(_wmakepath); ENTRY("_wmakepath (path=%p, drive=%p (%S), dir=%p (%S), fname=%p (%S), ext=%p (%S))\n", path, drive ? drive:W16_NULLSTRING, drive ? drive:W16_NULLSTRING, dir ? dir:W16_NULLSTRING, dir ? dir:W16_NULLSTRING, fname ? fname:W16_NULLSTRING, fname ? fname:W16_NULLSTRING, ext ? ext:W16_NULLSTRING, ext ? ext:W16_NULLSTRING); /* According to the pal documentation, host operating systems that don't support drive letters, the "drive" parameter must always be null. */ if ( drive != NULL && drive[0] != '\0' ) { ASSERT( "The drive parameter must always be NULL on systems that don't" "support drive letters. drive is being ignored!.\n" ); } if ((dir != NULL) && WideCharToMultiByte( CP_ACP, 0, dir, -1, Dir, _MAX_DIR, NULL, NULL ) == 0 ) { ASSERT( "An error occurred while converting dir to multibyte." "Possible error: Length of dir is greater than _MAX_DIR.\n" ); goto error; } if ((fname != NULL) && WideCharToMultiByte( CP_ACP, 0, fname, -1, FileName, _MAX_FNAME, NULL, NULL ) == 0 ) { ASSERT( "An error occurred while converting fname to multibyte." "Possible error: Length of fname is greater than _MAX_FNAME.\n" ); goto error; } if ((ext != NULL) && WideCharToMultiByte( CP_ACP, 0, ext, -1, Ext, _MAX_EXT, NULL, NULL ) == 0 ) { ASSERT( "An error occurred while converting ext to multibyte." "Possible error: Length of ext is greater than _MAX_EXT.\n" ); goto error; } /* Call up to the ANSI _makepath. */ _makepath_s( Path, sizeof(Path), NULL, Dir, FileName, Ext ); if ( MultiByteToWideChar( CP_ACP, 0, Path, -1, path, _MAX_PATH ) == 0 ) { ASSERT( "An error occurred while converting the back wide char." "Possible error: The length of combined path is greater " "than _MAX_PATH.\n" ); goto error; } LOGEXIT("_wmakepath returns void\n"); PERF_EXIT(_wmakepath); return; error: *path = '\0'; LOGEXIT("_wmakepath returns void\n"); PERF_EXIT(_wmakepath); }
void FilePath::SetExtension( String const &extension ) { m_extension = extension; _makepath_s( m_fullPath, m_fullPath.MaxLength(), m_drive, m_directory, m_fileName, m_extension ); }
void ParseArgs (int argc, char * const argv[], AudioFileTypeID & outFormat, Float64 & outSampleRate, OSType & outFileType, CFURLRef& outInputFileURL, CFURLRef& outOutputFileURL, UInt32 & outBitDepth, UInt32 & outBitRate) { if (argc < 2) { printf ("No Input File specified\n"); UsageString(1); } // support "ConvertFile -h" usage if (argc == 2 && !strcmp("-h", argv[1])) { UsageString(0); } // first validate our initial condition const char* inputFileName = argv[1]; outInputFileURL = CFURLCreateFromFileSystemRepresentation (kCFAllocatorDefault, (const UInt8 *)inputFileName, strlen(inputFileName), false); if (!outInputFileURL) { printf ("* * Bad input file path\n"); UsageString(1); } outBitRate = 0; outBitDepth = 0; // look to see if a format or different file output has been specified for (int i = 2; i < argc; ++i) { if (!strcmp ("-d", argv[i])) { str2OSType (argv[++i], outFormat); outSampleRate = 0; } else if (!strcmp ("-r", argv[i])) { sscanf (argv[++i], "%lf", &outSampleRate); outFormat = 0; } else if (!strcmp("-bd", argv[i])) { int temp; sscanf (argv[++i], "%d", &temp); outBitDepth = temp; } else if (!strcmp ("-f", argv[i])) { str2OSType (argv[++i], outFileType); } else if (!strcmp ("-b", argv[i])) { int temp; sscanf (argv[++i], "%u", &temp); outBitRate = temp; } else if (!strcmp ("-h", argv[i])) { UsageString(0); } else { printf ("* * Unknown command: %s\n", argv[i]); UsageString(1); } } // output file UInt32 size = sizeof(CFArrayRef); CFArrayRef extensions; OSStatus err = AudioFileGetGlobalInfo(kAudioFileGlobalInfo_ExtensionsForType, sizeof(OSType), &outFileType, &size, &extensions); XThrowIfError (err, "Getting the file extensions for file type"); // just take the first extension CFStringRef ext = (CFStringRef)CFArrayGetValueAtIndex(extensions, 0); char extstr[32]; Boolean res = CFStringGetCString(ext, extstr, 32, kCFStringEncodingUTF8); XThrowIfError (!res, "CFStringGetCString"); // release the array as we're done with this now CFRelease (extensions); char outFname[256]; #if TARGET_OS_WIN32 char drive[3], dir[256]; _splitpath_s(inputFileName, drive, 3, dir, 256, NULL, 0, NULL, 0); _makepath_s(outFname, 256, drive, dir, "outfile", extstr); #else // char outFname[64]; sprintf (outFname, "/tmp/outfile.%s", extstr); #endif outOutputFileURL = CFURLCreateFromFileSystemRepresentation (kCFAllocatorDefault, (const UInt8 *)outFname, strlen(outFname), false); if (!outOutputFileURL) { printf ("* * Bad output file path\n"); UsageString(1); } }
BOOL __stdcall AtlTraceLoadSettingsA(const CHAR *pszFileName, DWORD_PTR dwProcess /* = 0 */) { CHAR szFileName[_MAX_PATH]; if(!pszFileName) { CHAR szDrive[_MAX_DRIVE]; CHAR szDir[_MAX_DIR]; CHAR szFName[_MAX_FNAME]; CHAR szExt[_MAX_EXT]; DWORD dwret = ::GetModuleFileNameA(NULL, szFileName, MAX_PATH); if( dwret == 0 || dwret == MAX_PATH ) return FALSE; #if _SECURE_ATL ATL_CRT_ERRORCHECK(_splitpath_s(szFileName, szDrive, _countof(szDrive), szDir, _countof(szDir), szFName, _countof(szFName), szExt, _countof(szExt))); ATL_CRT_ERRORCHECK(strncpy_s(szExt, _MAX_EXT, TRACE_SETTINGS_EXT, sizeof(TRACE_SETTINGS_EXT))); ATL_CRT_ERRORCHECK(_makepath_s(szFileName, _MAX_PATH, szDrive, szDir, szFName, szExt)); #else _splitpath(szFileName, szDrive, szDir, szFName, szExt); strcpy(szExt, ".trc"); _makepath(szFileName, szDrive, szDir, szFName, szExt); #endif pszFileName = szFileName; } if(pszFileName) { if(-1 != GetFileAttributesA(pszFileName)) { // file exists CHAR szSection[MAX_PATH], szKey[MAX_PATH], szValue[MAX_PATH]; CHAR szName[MAX_PATH]; UINT nModules, nCategories, nStatus, nLevel; UINT nModule; CAtlTraceProcess *pProcess; CAtlTraceModule *pModule; CAtlTraceCategory *pCategory; CHAR *pszProcess = "Process"; CHAR cEnabled, cFuncAndCategoryNames, cFileNameAndLineInfo; CAtlAllocator *pAllocator = &g_Allocator; if (dwProcess) pAllocator = reinterpret_cast<CAtlAllocator*>(dwProcess); pProcess = pAllocator->GetProcess(); ATLASSERT(pProcess); if(!pProcess) return FALSE; pProcess->m_bLoaded = true; ::GetPrivateProfileStringA(pszProcess, "Info", "", szValue, MAX_PATH, pszFileName); szValue[MAX_PATH - 1] = 0; #if _SECURE_ATL if(5 != sscanf_s(szValue, "ModuleCount:%u, Level:%u, Enabled:%c, " "FuncAndCategoryNames:%c, FileNameAndLineNo:%c", &nModules, &pProcess->m_nLevel, &cEnabled, sizeof(cEnabled), &cFuncAndCategoryNames, sizeof(cFuncAndCategoryNames), &cFileNameAndLineInfo, sizeof(cFileNameAndLineInfo))) #else if(5 != sscanf(szValue, "ModuleCount:%u, Level:%u, Enabled:%c, " "FuncAndCategoryNames:%c, FileNameAndLineNo:%c", &nModules, &pProcess->m_nLevel, &cEnabled, &cFuncAndCategoryNames, &cFileNameAndLineInfo)) #endif { return FALSE; } pProcess->m_bEnabled = cEnabled != 'f'; pProcess->m_bFuncAndCategoryNames = cFuncAndCategoryNames != 'f'; pProcess->m_bFileNameAndLineNo = cFileNameAndLineInfo != 'f'; for(UINT i = 0; i < nModules; i++) { #if _SECURE_ATL if(-1 == sprintf_s(szKey, MAX_PATH, "Module%d", i+1)) return FALSE; #else sprintf(szKey, "Module%d", i+1); #endif ::GetPrivateProfileStringA(pszProcess, szKey, "", szSection, MAX_PATH, pszFileName); szSection[MAX_PATH -1] = 0; ::GetPrivateProfileStringA(szSection, "Name", "", szName, MAX_PATH, pszFileName); szName[MAX_PATH -1] = 0; if(!pAllocator->FindModule(CA2W(szName), &nModule)) continue; pModule = pAllocator->GetModule(nModule); ATLASSERT(pModule); if(!pModule) continue; ::GetPrivateProfileStringA(szSection, "Settings", "", szValue, MAX_PATH, pszFileName); szValue[MAX_PATH -1] = 0; #if _SECURE_ATL if(3 != sscanf_s(szValue, "CategoryCount:%u, Level:%u, Status:%u", &nCategories, &nLevel, &nStatus)) #else if(3 != sscanf(szValue, "CategoryCount:%u, Level:%u, Status:%u", &nCategories, &nLevel, &nStatus)) #endif continue; SetSettings(pModule, nLevel, nStatus); for(UINT j = 0; j < nCategories; j++) { #if _SECURE_ATL if(-1 == sprintf_s(szKey, MAX_PATH, "Category%d", j+1)) return FALSE; #else sprintf(szKey, "Category%d", j+1); #endif ::GetPrivateProfileStringA(szSection, szKey, "", szValue, MAX_PATH, pszFileName); szValue[MAX_PATH -1] = 0; #if _SECURE_ATL if(3 != sscanf_s(szValue, "Level:%u, Status:%u, Name:%s", &nLevel, &nStatus, szName, _countof(szName))) #else if(3 != sscanf(szValue, "Level:%u, Status:%u, Name:%s", &nLevel, &nStatus, szName)) #endif continue; UINT iCategory = pModule->m_iFirstCategory; while( iCategory != UINT( -1 ) ) { pCategory = pAllocator->GetCategory(iCategory); if( lstrcmpA(CW2A(pCategory->Name()), szName) == 0 ) { SetSettings(pCategory, nLevel, nStatus); } iCategory = pCategory->m_iNextCategory; } } } NotifyTool(); } } return TRUE; }
// main関数 int main(int argc, char* argv[]) { // 引数解釈 const char* makefile = NULL; const char* top_dir = NULL; for (int i=1; i < argc; i++) { char* p = argv[i]; if (*p == '/' || *p =='-') { p++; if (_strnicmp(p,"file",4) == 0) { p += 4; if (*p == '\0') { if (i < argc) { makefile = argv[++i]; } } else { if (*p == '=') p++; makefile = p; } } else if (_strnicmp(p,"dir",3) == 0) { p += 3; if (*p == '\0') { if (i < argc) { top_dir = argv[++i]; } } else { if (*p == '=') p++; top_dir = p; } } else { printf("Error: 不明な引数[%s]\n", argv[i]); return usage(); } } else { printf("Error: 不明な引数[%s]\n", argv[i]); return usage(); } } if (makefile == NULL && top_dir != NULL) { return usage(); } if (!makefile) { printf("Error: makefileを指定してください\n\n"); return usage(); } if (!top_dir) { printf("Error: トップディレクトリを指定してください\n\n"); return usage(); } // トップディレクトリのチェック struct stat st; int ret = stat( top_dir, &st ); if (ret != 0 || !(st.st_mode & _S_IFDIR)) { printf("Error: トップディレクトリ[%s]が見つかりません\n", top_dir); return 1; } // ファイルオープン FILE* in = NULL; if (fopen_s( &in, makefile, "rt" ) != 0) { printf("Error: 出力ファイル[%s]を開けません\n", makefile); return 1; } // テンポラリファイルの作成 char tmp_file[_MAX_PATH]; char drive[_MAX_DRIVE], dir[_MAX_DIR]; if (_splitpath_s( makefile, drive, _countof(drive), dir, _countof(dir), NULL, 0, NULL, 0 )) { printf("Error: 一時ファイル名を作れません[%s]\n", makefile); return 1; } if (_makepath_s( tmp_file, _countof(tmp_file), drive, dir, "mfXXXXXX", NULL )) { printf("Error: 一時ファイル名を作れません[%s, %s]\n", drive, dir); return 1; } if (_mktemp_s(tmp_file, _countof(tmp_file))) { printf("Error: 一時ファイル名を作れません[%s]\n", tmp_file); return 1; } FILE* out = NULL; if (fopen_s( &out, tmp_file, "wt" ) != 0) { printf("Error: 一時ファイル[%s]を開けません\n", tmp_file); return 1; } // ファイルリストの作成 makeFileListTop(top_dir); // ファイルの書替え int mode = 0; // 0:.obj前 1:.obj中 2:.obj後 bool change = false; // 変更あり char line[1024]; char mkline[1024]; char* wtline; const char* fl_nm; while (fgets(line, _countof(line), in) != NULL) { wtline = line; switch (mode) { case 0: if (strstr(line, "OBJS")) { mode = 1; } break; case 1: if (line[0] == '\n' || line[0] == '\0') { // リスト終了? fl_nm = getFile(); if (fl_nm != NULL) { // ファイルが増えた change = true; do { //出力 fprintf(out, "%s", makeObjLine( mkline, _countof(mkline), fl_nm ) ); } while ((fl_nm = getFile()) != NULL); } mode = 2; } else { fl_nm = getFile(); if (fl_nm == NULL) { // ファイルが減った change = true; continue; } makeObjLine( mkline, _countof(mkline), fl_nm ); // 変更有りか? if (!change && strcmp(line, mkline) != 0) change = true; wtline = mkline; } break; case 2: break; } //出力 fprintf(out,"%s", wtline); } // close fclose(in); fclose(out); #ifdef _DEBUG printf("%d個のオブジェクトファイル名が出力されました\n", file_list.size()); #endif // ファイルの入換え if (change) { if (remove(makefile)) { printf("Error: makefile[%s]を削除出来ません\n", tmp_file); return 1; } if (rename( tmp_file, makefile )) { printf("Error: 一時ファイル[%s]をmakfile[%s]に出来ません\n", tmp_file, makefile); return 1; } } else { if (remove(tmp_file)) { printf("Warning: 一時ファイル[%s]を削除出来ません\n", tmp_file); } printf("出力ファイルは最新です\n"); } return 0; }
void FilePath::SetFileName( String const &fileName ) { m_fileName = fileName; _makepath_s( m_fullPath, m_fullPath.MaxLength(), m_drive, m_directory, m_fileName, m_extension ); }