本文整理汇总了C++中PathIsRelative函数的典型用法代码示例。如果您正苦于以下问题:C++ PathIsRelative函数的具体用法?C++ PathIsRelative怎么用?C++ PathIsRelative使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PathIsRelative函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: make_url
void web_page::set_base_url( const litehtml::tchar_t* base_url )
{
#ifndef LITEHTML_UTF8
if(base_url)
{
if(PathIsRelative(base_url) && !PathIsURL(base_url))
{
make_url(base_url, m_url.c_str(), m_base_path);
} else
{
m_base_path = base_url;
}
} else
{
m_base_path = m_url;
}
#else
LPWSTR bu = cairo_font::utf8_to_wchar(base_url);
if(bu)
{
if(PathIsRelative(bu) && !PathIsURL(bu))
{
make_url(bu, m_url.c_str(), m_base_path);
} else
{
m_base_path = bu;
}
} else
{
m_base_path = m_url;
}
#endif
}
示例2: UpdateData
void CProjectNew::OnOK()
{
UpdateData(TRUE);
if ( m_strName.IsEmpty() )
{
AfxMessageBox("Project name cannot be empty string.");
return;
}
if ( PathIsRelative(m_strProjectDir) )
{
AfxMessageBox("Path to project directory must be absolute.");
return;
}
if ( GetFileAttributes(m_strProjectDir)!=FILE_ATTRIBUTE_DIRECTORY &&
!CreateDirectory(m_strProjectDir, NULL) )
{
AfxMessageBox("Cannot create project directory.");
return;
}
int nItem = m_types.GetNextItem(-1, LVNI_SELECTED|LVNI_ALL);
if ( nItem==-1 )
{
AfxMessageBox("Select project type.");
return;
}
m_nType = m_types.GetItemData(nItem);
CDialog::OnOK();
}
示例3: md_dir_set
/// Directory handling
/// ==================
BOOL md_dir_set(UINT32 dir_seg4, UINT16 dir_off) {
CHAR dir_raw[MAX_PATH];
TCHAR dir_ucs2[MAX_PATH];
OEMCHAR *dos_dir;
OEMCHAR *real_dir;
BOOL ret;
dos_dir = mem_read_sjis2ucs2(dir_raw, dir_ucs2, dir_seg4, dir_off, MAX_PATH);
real_dir = md_drive_parse(dos_dir);
// Changing to an empty string would lead to an error, crashing DOS
if(real_dir[0] == _T('\0')) {
ret = 1;
} else {
ret = SetCurrentDirectory(real_dir);
}
// Don't set errors here!
// Changing the registers quickly leads to
// DOS crashing inside its own DIR function
if(ret) {
if(PathIsRelative(dos_dir)) {
OEMCHAR tmp[MAX_PATH];
lstrcpy(tmp, cur_dir);
PathAddBackslash(tmp);
lstrcat(tmp, real_dir);
PathCanonicalize(cur_dir, tmp);
} else {
lstrcpy(cur_dir, real_dir);
}
}
// Don't override DOS' handling of this one
return FALSE;
}
示例4: UpdateData
void CRenameDlg::OnOK()
{
UpdateData();
m_name.Trim();
bool nameAllowed = ((m_originalName != m_name) || !m_renameRequired) && !m_name.IsEmpty();
if (!nameAllowed)
{
m_bBalloonVisible = true;
ShowEditBalloon(IDC_NAME, IDS_WARN_RENAMEREQUIRED, IDS_ERR_ERROR, TTI_ERROR);
return;
}
CTGitPath path(m_name);
if (!path.IsValidOnWindows() || !PathIsRelative(m_name))
{
m_bBalloonVisible = true;
ShowEditBalloon(IDC_NAME, IDS_WARN_NOVALIDPATH, IDS_ERR_ERROR, TTI_ERROR);
return;
}
if (m_pInputValidator)
{
CString sError = m_pInputValidator(IDC_NAME, m_name);
if (!sError.IsEmpty())
{
m_bBalloonVisible = true;
ShowEditBalloon(IDC_NAME, sError, CString(MAKEINTRESOURCE(IDS_ERR_ERROR)), TTI_ERROR);
return;
}
}
CHorizontalResizableStandAloneDialog::OnOK();
}
示例5: expand_dirname
// converts relative path to absolute path
int expand_dirname(char *dirname, char *drive)
{
char relative[MAX_PATH];
char absolute[MAX_PATH];
BOOL status;
if (PathIsRelative(dirname))
{
_ASSERTE(strlen(drive) < NUM_OF(relative));
strcpy(relative, drive);
_ASSERTE(strlen(relative) + strlen(dirname) < NUM_OF(relative));
strcat(relative, dirname);
status = PathSearchAndQualify(relative, absolute, NUM_OF(absolute));
_ASSERTE(status);
if (':' == absolute[1])
{
drive[0] = absolute[0];
drive[1] = absolute[1];
drive[2] = 0;
strcpy(dirname, &absolute[2]);
}
else
{
strcpy(dirname, absolute);
}
}
fix_dirname(dirname);
return 0;
}
示例6: _wfsopen
/**
* Returns the .git-path (if .git is a file, read the repository path and return it)
* adminDir always ends with "\"
*/
bool GitAdminDir::GetAdminDirPath(const CString& projectTopDir, CString& adminDir, bool* isWorktree)
{
CString wtAdminDir;
if (!GetWorktreeAdminDirPath(projectTopDir, wtAdminDir))
return false;
CString pathToCommonDir = wtAdminDir + L"commondir";
if (!PathFileExists(pathToCommonDir))
{
adminDir = wtAdminDir;
if (isWorktree)
*isWorktree = false;
return true;
}
CAutoFILE pFile = _wfsopen(pathToCommonDir, L"rb", SH_DENYWR);
if (!pFile)
return false;
int size = 65536;
CStringA commonDirA;
int length = (int)fread(commonDirA.GetBufferSetLength(size), sizeof(char), size, pFile);
commonDirA.ReleaseBuffer(length);
CString commonDir = CUnicodeUtils::GetUnicode(commonDirA);
commonDir.TrimRight(L"\r\n");
commonDir.Replace(L'/', L'\\');
if (PathIsRelative(commonDir))
adminDir = CPathUtils::BuildPathWithPathDelimiter(wtAdminDir + commonDir);
else
adminDir = CPathUtils::BuildPathWithPathDelimiter(commonDir);
if (isWorktree)
*isWorktree = true;
return true;
}
示例7: GetLongPathname
CString CPathUtils::GetLongPathname(const CString& path)
{
if (path.IsEmpty())
return path;
TCHAR pathbufcanonicalized[MAX_PATH]; // MAX_PATH ok.
DWORD ret = 0;
CString sRet;
if (!PathIsURL(path) && PathIsRelative(path))
{
ret = GetFullPathName(path, 0, NULL, NULL);
if (ret)
{
std::unique_ptr<TCHAR[]> pathbuf(new TCHAR[ret + 1]);
if ((ret = GetFullPathName(path, ret, pathbuf.get(), NULL)) != 0)
sRet = CString(pathbuf.get(), ret);
}
}
else if (PathCanonicalize(pathbufcanonicalized, path))
{
ret = ::GetLongPathName(pathbufcanonicalized, NULL, 0);
std::unique_ptr<TCHAR[]> pathbuf(new TCHAR[ret + 2]);
ret = ::GetLongPathName(pathbufcanonicalized, pathbuf.get(), ret + 1);
sRet = CString(pathbuf.get(), ret);
}
else
{
ret = ::GetLongPathName(path, NULL, 0);
std::unique_ptr<TCHAR[]> pathbuf(new TCHAR[ret + 2]);
ret = ::GetLongPathName(path, pathbuf.get(), ret + 1);
sRet = CString(pathbuf.get(), ret);
}
if (ret == 0)
return path;
return sRet;
}
示例8: vInitailizeSimSysInfo
void CSimSysManager::vSetConfigData(xmlNodePtr pNode)
{
INT nWndPos = S_FALSE;
vInitailizeSimSysInfo();
if( NULL != pNode )
{
pNode = pNode->xmlChildrenNode;
while (pNode != NULL)
{
if ((!xmlStrcmp(pNode->name, (const xmlChar*)"Window_Position")))
{
nWndPos = xmlUtils::ParseWindowsPlacement(pNode, CGlobalObj::ouGetObj(m_eBus).m_wWindowPlacement);
}
if ((!xmlStrcmp(pNode->name, (const xmlChar*)"Sym_Path")))
{
xmlChar* key = xmlNodeListGetString(pNode->doc, pNode->xmlChildrenNode, 1);
if(NULL != key)
{
CString omStrFileName;
if(PathIsRelative((char*)key) == TRUE)
{
std::string omStrConfigFolder;
std::string omPath;
char configPath[MAX_PATH];
AfxGetMainWnd()->SendMessage(MSG_GET_CONFIGPATH, (WPARAM)configPath, 0);
CUtilFunctions::nGetBaseFolder(configPath, omStrConfigFolder );
char chAbsPath[MAX_PATH];
PathCombine(chAbsPath, omStrConfigFolder.c_str(), (char*)key);
omStrFileName = chAbsPath;
}
else
{
omStrFileName = (char*)key;
}
vLoadSimInfoFromConfiguration((char*)omStrFileName.GetBuffer(MAX_PATH));
xmlFree(key);
}
}
pNode = pNode->next;
}
}
if(nWndPos == S_FALSE)
{
/*CGlobalObj::ouGetObj(m_eBus).m_wWindowPlacement.rcNormalPosition.top = 160;
CGlobalObj::ouGetObj(m_eBus).m_wWindowPlacement.rcNormalPosition.left = 520;
CGlobalObj::ouGetObj(m_eBus).m_wWindowPlacement.rcNormalPosition.right = 1458;
CGlobalObj::ouGetObj(m_eBus).m_wWindowPlacement.rcNormalPosition.bottom = 686;
CGlobalObj::ouGetObj(m_eBus).m_wWindowPlacement.showCmd = SW_NORMAL;*/
CGlobalObj::ouGetObj(m_eBus).bGetDefaultValue(SIMSYS_WND_PLACEMENT, CGlobalObj::ouGetObj(m_eBus).m_wWindowPlacement);
}
if (m_pomSimSysTreeView != NULL)
{
if (m_pomSimSysTreeView->IsWindowVisible())
{
m_pomSimSysTreeView->bPopulateTree();
}
}
}
示例9: MakeAbsolutePath
void CChordEaseApp::MakeAbsolutePath(CString& Path)
{
if (PathIsRelative(Path)) { // if path is relative
CPathStr AbsPath(GetDataFolderPath());
AbsPath.Append(Path);
Path = AbsPath;
}
}
示例10: I_GetUserFileName
std::string I_GetUserFileName (const char *file)
{
#if defined(UNIX) && !defined(GEKKO)
// return absolute or explicitly relative pathnames unmodified,
// so launchers or CLI/console users have control over netdemo placement
if (file &&
(file[0] == PATHSEPCHAR || // /path/to/file
(file[0] == '.' && file[1] == PATHSEPCHAR) || // ./file
(file[0] == '.' && file[1] == '.' && file[2] == PATHSEPCHAR))) // ../file
return std::string (file);
std::string path = I_GetHomeDir();
if(path[path.length() - 1] != PATHSEPCHAR)
path += PATHSEP;
path += ".odamex";
struct stat info;
if (stat (path.c_str(), &info) == -1)
{
if (mkdir (path.c_str(), S_IRUSR | S_IWUSR | S_IXUSR) == -1)
{
I_FatalError ("Failed to create %s directory:\n%s",
path.c_str(), strerror (errno));
}
}
else
{
if (!S_ISDIR(info.st_mode))
{
I_FatalError ("%s must be a directory", path.c_str());
}
}
path += PATHSEP;
path += file;
#elif defined(_XBOX)
std::string path = "T:";
path += PATHSEP;
path += file;
#else
if (!PathIsRelative(file))
return std::string (file);
std::string path = I_GetBinaryDir();
if(path[path.length() - 1] != PATHSEPCHAR)
path += PATHSEP;
path += file;
#endif
FixPathSeparator(path);
return path;
}
示例11: LRCTitleFormatCallback
std::wstring LyricSourceLRC::getSavePath(const metadb_handle_ptr &track)
{
std::string path = track->get_path();
std::wstring wpath = EncodingFunc::ToUTF16(path.substr(boost::find_last(path, "://").end() - path.begin()));
wpath = wpath.substr(0, wpath.find_last_of(L"."));
if(track->get_subsong_index() != 0)
wpath += boost::lexical_cast<std::wstring>(track->get_subsong_index());
wpath += L".lrc";
if(m_config["lrcsavepath"].length())
{
class LRCTitleFormatCallback : public main_thread_callback
{
private:
HANDLE m_event;
std::string *m_out;
const std::string &m_format;
const metadb_handle_ptr &m_track;
public:
LRCTitleFormatCallback(HANDLE event, std::string *out, const std::string &format, const metadb_handle_ptr &track) : m_event(event), m_format(format), m_out(out), m_track(track) {}
virtual void callback_run()
{
core_api::ensure_main_thread();
pfc::string8 out;
service_ptr_t<titleformat_object> script;
static_api_ptr_t<titleformat_compiler>()->compile(script, m_format.c_str());
m_track->format_title(NULL, out, script, NULL);
m_out->assign(out.get_ptr());
SetEvent(m_event);
}
};
std::wstring dirname = wpath.substr(0, wpath.find_last_of(L'\\') + 1);
std::wstring filename = wpath.substr(wpath.find_last_of(L"\\") + 1);
HANDLE event = CreateEvent(NULL, TRUE, FALSE, NULL);
std::string out;
std::string pathtmp = m_config["lrcsavepath"];
if(pathtmp.at(pathtmp.length() - 1) != '\\')
pathtmp += '\\';
service_ptr_t<LRCTitleFormatCallback> p_callback = new service_impl_t<LRCTitleFormatCallback>(event, &out, pathtmp, track);
static_api_ptr_t<main_thread_callback_manager>()->add_callback(p_callback);
p_callback.release();
WaitForSingleObject(event, INFINITE);
CloseHandle(event);
wpath = EncodingFunc::ToUTF16(out);
if(PathIsRelative(wpath.c_str()))
wpath = dirname + wpath;
if(GetFileAttributes(wpath.c_str()) & FILE_ATTRIBUTE_DIRECTORY && (GetLastError() != ERROR_FILE_NOT_FOUND && GetLastError() != ERROR_PATH_NOT_FOUND))
wpath += filename;
return wpath;
}
if(path.find_first_of("file://") == std::string::npos)
return std::wstring(L"");
if(path.find_first_of("unpack://") == std::string::npos)
return std::wstring(L"");
return wpath;
}
示例12: GetFullPath
CString CFilePatchesDlg::GetFullPath(int nIndex)
{
CString temp = m_pPatch->GetStrippedPath(nIndex);
temp.Replace('/', '\\');
//temp = temp.Mid(temp.Find('\\')+1);
if (PathIsRelative(temp))
temp = m_sPath + temp;
return temp;
}
示例13: is_definite
int is_definite( const char * filename )
{
#ifdef _UNIX_
return (filename[0] == '/') || (filename[0] == '.');
#else // Should we assume windows?!
// Windows impl
return (PathIsRelative( filename ) == FALSE) || (filename[0] == '.');
#endif
}
示例14: dl_open
static void*
dl_open(const char* name, int flags)
{
if (name == NULL) {
return GetModuleHandle(NULL);
} else {
DWORD dwFlags = PathIsRelative(name) ? 0 : LOAD_WITH_ALTERED_SEARCH_PATH;
return LoadLibraryEx(name, NULL, dwFlags);
}
}
示例15: _T
bool SubmoduleAddCommand::Execute()
{
bool bRet = false;
CSubmoduleAddDlg dlg;
dlg.m_strPath = cmdLinePath.GetDirectory().GetWinPathString();
dlg.m_strProject = g_Git.m_CurrentDir;
if( dlg.DoModal() == IDOK )
{
if (dlg.m_bAutoloadPuttyKeyFile)
CAppUtils::LaunchPAgent(&dlg.m_strPuttyKeyFile);
CString cmd;
if(dlg.m_strPath.Left(g_Git.m_CurrentDir.GetLength()) == g_Git.m_CurrentDir)
dlg.m_strPath = dlg.m_strPath.Right(dlg.m_strPath.GetLength()-g_Git.m_CurrentDir.GetLength()-1);
CString branch;
if(dlg.m_bBranch)
branch.Format(_T(" -b %s "), (LPCTSTR)dlg.m_strBranch);
CString force;
if (dlg.m_bForce)
force = _T("--force");
dlg.m_strPath.Replace(_T('\\'),_T('/'));
dlg.m_strRepos.Replace(_T('\\'),_T('/'));
cmd.Format(_T("git.exe submodule add %s %s -- \"%s\" \"%s\""),
(LPCTSTR)branch, (LPCTSTR)force,
(LPCTSTR)dlg.m_strRepos, (LPCTSTR)dlg.m_strPath);
CProgressDlg progress;
progress.m_GitCmd=cmd;
progress.DoModal();
if (progress.m_GitStatus == 0)
{
if (dlg.m_bAutoloadPuttyKeyFile)
{
SetCurrentDirectory(g_Git.m_CurrentDir);
CGit subgit;
dlg.m_strPath.Replace(_T('/'), _T('\\'));
subgit.m_CurrentDir = PathIsRelative(dlg.m_strPath) ? g_Git.CombinePath(dlg.m_strPath) : dlg.m_strPath;
if (subgit.SetConfigValue(_T("remote.origin.puttykeyfile"), dlg.m_strPuttyKeyFile, CONFIG_LOCAL))
{
CMessageBox::Show(NULL, _T("Fail set config remote.origin.puttykeyfile"), _T("TortoiseGit"), MB_OK| MB_ICONERROR);
return FALSE;
}
}
}
bRet = TRUE;
}
return bRet;
}