本文整理汇总了C++中OsPath::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ OsPath::empty方法的具体用法?C++ OsPath::empty怎么用?C++ OsPath::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OsPath
的用法示例。
在下文中一共展示了OsPath::empty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OsPath
/*static*/ OsPath Paths::Root(const OsPath& argv0)
{
#if OS_ANDROID
return OsPath("/sdcard/0ad"); // TODO: this is kind of bogus
#else
// get full path to executable
OsPath pathname = sys_ExecutablePathname(); // safe, but requires OS-specific implementation
if(pathname.empty()) // failed, use argv[0] instead
{
errno = 0;
pathname = wrealpath(argv0);
if(pathname.empty())
WARN_IF_ERR(StatusFromErrno());
}
// make sure it's valid
if(!FileExists(pathname))
{
LOGERROR(L"Cannot find executable (expected at '%ls')", pathname.string().c_str());
WARN_IF_ERR(StatusFromErrno());
}
for(size_t i = 0; i < 2; i++) // remove "system/name.exe"
pathname = pathname.Parent();
return pathname;
#endif
}
示例2: CreateDirectories
Status CreateDirectories(const OsPath& path, mode_t mode, bool breakpoint)
{
if(path.empty())
return INFO::OK;
struct stat s;
if(wstat(path, &s) == 0)
{
if(!S_ISDIR(s.st_mode)) // encountered a file
WARN_RETURN(ERR::FAIL);
return INFO::OK;
}
// If we were passed a path ending with '/', strip the '/' now so that
// we can consistently use Parent to find parent directory names
if(path.IsDirectory())
return CreateDirectories(path.Parent(), mode, breakpoint);
RETURN_STATUS_IF_ERR(CreateDirectories(path.Parent(), mode));
errno = 0;
if(wmkdir(path, mode) != 0)
{
debug_printf("CreateDirectories: failed to mkdir %s (mode %d)\n", path.string8().c_str(), mode);
if (breakpoint)
WARN_RETURN(StatusFromErrno());
else
return StatusFromErrno();
}
return INFO::OK;
}
示例3: sys_ExecutablePathname
OsPath sys_ExecutablePathname()
{
OsPath path;
// On OS X we might be a bundle, return the bundle path as the executable name,
// i.e. /path/to/0ad.app instead of /path/to/0ad.app/Contents/MacOS/pyrogenesis
if (osx_IsAppBundleValid())
{
path = osx_GetBundlePath();
ENSURE(!path.empty());
}
else
{
char temp[PATH_MAX];
u32 size = PATH_MAX;
if (_NSGetExecutablePath(temp, &size) == 0)
{
char name[PATH_MAX];
realpath(temp, name);
path = OsPath(name);
}
}
return path;
}
示例4: wdll_ver_Append
void wdll_ver_Append(const OsPath& pathname, VersionList& list)
{
if(pathname.empty())
return; // avoid error in ReadVersionString
// pathname may not have an extension (e.g. driver names from the
// registry). note that always appending ".dll" would be incorrect
// since some have ".sys" extension.
OsPath modulePathname(pathname);
if(modulePathname.Extension() == "")
modulePathname = modulePathname.ChangeExtension(L".dll");
const OsPath moduleName(modulePathname.Filename());
// read file version. try this with and without FS redirection since
// pathname might assume both.
wchar_t versionString[500]; // enclosed in () below
if(ReadVersionString(modulePathname, versionString, ARRAY_SIZE(versionString)) != INFO::OK)
{
WinScopedDisableWow64Redirection s;
// still failed; avoid polluting list with DLLs that don't exist
// (requiring callers to check for their existence beforehand would be
// onerous and unreliable)
if(ReadVersionString(modulePathname, versionString, ARRAY_SIZE(versionString)) != INFO::OK)
return;
}
if(!list.empty())
list += L", ";
list += moduleName.Filename().string();
list += L" (";
list += versionString;
list += L")";
}
示例5: wrealpath
/*static*/ OsPath Paths::Root(const OsPath& argv0)
{
// get full path to executable
OsPath pathname = sys_ExecutablePathname(); // safe, but requires OS-specific implementation
if(pathname.empty()) // failed, use argv[0] instead
{
errno = 0;
pathname = wrealpath(argv0);
if(pathname.empty())
WARN_IF_ERR(StatusFromErrno());
}
// make sure it's valid
if(!FileExists(pathname))
WARN_IF_ERR(StatusFromErrno());
for(size_t i = 0; i < 2; i++) // remove "system/name.exe"
pathname = pathname.Parent();
return pathname;
}