本文整理汇总了C++中OsPath::Parent方法的典型用法代码示例。如果您正苦于以下问题:C++ OsPath::Parent方法的具体用法?C++ OsPath::Parent怎么用?C++ OsPath::Parent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OsPath
的用法示例。
在下文中一共展示了OsPath::Parent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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
}
示例3: file
void CSimulation2Impl::DumpState()
{
PROFILE("DumpState");
std::stringstream pid;
pid << getpid();
std::stringstream name;\
name << std::setw(5) << std::setfill('0') << m_TurnNumber << ".txt";
OsPath path = psLogDir() / "sim_log" / pid.str() / name.str();
CreateDirectories(path.Parent(), 0700);
std::ofstream file (OsString(path).c_str(), std::ofstream::out | std::ofstream::trunc);
file << "State hash: " << std::hex;
std::string hashRaw;
m_ComponentManager.ComputeStateHash(hashRaw, false);
for (size_t i = 0; i < hashRaw.size(); ++i)
file << std::setfill('0') << std::setw(2) << (int)(unsigned char)hashRaw[i];
file << std::dec << "\n";
file << "\n";
m_ComponentManager.DumpDebugState(file, true);
std::ofstream binfile (OsString(path.ChangeExtension(L".dat")).c_str(), std::ofstream::out | std::ofstream::trunc | std::ofstream::binary);
m_ComponentManager.SerializeState(binfile);
}
示例4: GetVirtualPath
virtual Status GetVirtualPath(const OsPath& realPathname, VfsPath& pathname)
{
ScopedLock s;
const OsPath realPath = realPathname.Parent()/"";
VfsPath path;
RETURN_STATUS_IF_ERR(FindRealPathR(realPath, m_rootDirectory, L"", path));
pathname = path / realPathname.Filename();
return INFO::OK;
}
示例5: getpid
CReplayLogger::CReplayLogger(ScriptInterface& scriptInterface) :
m_ScriptInterface(scriptInterface)
{
// Construct the directory name based on the PID, to be relatively unique.
// Append "-1", "-2" etc if we run multiple matches in a single session,
// to avoid accidentally overwriting earlier logs.
std::wstringstream name;
name << getpid();
static int run = -1;
if (++run)
name << "-" << run;
OsPath path = psLogDir() / L"sim_log" / name.str() / L"commands.txt";
CreateDirectories(path.Parent(), 0700);
m_Stream = new std::ofstream(OsString(path).c_str(), std::ofstream::out | std::ofstream::trunc);
}
示例6: 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;
}