本文整理汇总了C++中fs::path::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ path::begin方法的具体用法?C++ path::begin怎么用?C++ path::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fs::path
的用法示例。
在下文中一共展示了path::begin方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: relative_path
fs::path relative_path(const fs::path& inFromDir, const fs::path& inFile)
{
// assert(false);
fs::path::iterator d = inFromDir.begin();
fs::path::iterator f = inFile.begin();
while (d != inFromDir.end() and f != inFile.end() and *d == *f)
{
++d;
++f;
}
fs::path result;
if (d == inFromDir.end() and f == inFile.end())
result = ".";
else
{
while (d != inFromDir.end())
{
result /= "..";
++d;
}
while (f != inFile.end())
{
result /= *f;
++f;
}
}
return result;
}
示例2: MakeRelative
fs::path Path::MakeRelative(fs::path const& path, fs::path const& base) const {
if (path.empty() || base.empty()) return path;
const auto str = path.string();
if (boost::starts_with(str, "?dummy") || boost::starts_with(str, "dummy-audio:"))
return path;
// Paths on different volumes can't be made relative to each other
if (path.has_root_name() && path.root_name() != base.root_name())
return path.string();
auto path_it = path.begin();
auto ref_it = base.begin();
for (; path_it != path.end() && ref_it != base.end() && *path_it == *ref_it; ++path_it, ++ref_it) ;
agi::fs::path result;
for (; ref_it != base.end(); ++ref_it)
result /= "..";
for (; path_it != path.end(); ++path_it)
result /= *path_it;
return result;
}
示例3: add_file
void file_storage::add_file(fs::path const& file, size_type size, int flags
, std::time_t mtime, fs::path const& symlink_path)
{
TORRENT_ASSERT(size >= 0);
#if BOOST_VERSION < 103600
if (!file.has_branch_path())
#else
if (!file.has_parent_path())
#endif
{
// you have already added at least one file with a
// path to the file (branch_path), which means that
// all the other files need to be in the same top
// directory as the first file.
TORRENT_ASSERT(m_files.empty());
m_name = file.string();
}
else
{
if (m_files.empty())
m_name = *file.begin();
}
TORRENT_ASSERT(m_name == *file.begin());
m_files.push_back(file_entry());
file_entry& e = m_files.back();
e.size = size;
e.path = file;
e.offset = m_total_size;
e.pad_file = bool(flags & pad_file);
e.hidden_attribute = bool(flags & attribute_hidden);
e.executable_attribute = bool(flags & attribute_executable);
e.symlink_attribute = bool(flags & attribute_symlink);
if (e.symlink_attribute) e.symlink_path = symlink_path.string();
e.mtime = mtime;
m_total_size += size;
}
示例4: is_in_home
bool can::is_in_home(const fs::path& file)
{
fs::path home{user::current().get_HOME()};
for (auto it = home.begin(), file_it = file.begin();
it != home.end() && file_it != file.end();
it++, file_it++)
{
if (*it != *file_it)
{
return false;
}
}
return true;
}
示例5: AddEntry
void MResourceFileImp::AddEntry(
fs::path inPath,
const char* inData,
uint32 inSize)
{
uint32 node = 0; // start at root
for (fs::path::iterator p = inPath.begin(); p != inPath.end(); ++p)
{
// no such child? Add it and continue
if (mIndex[node].mChild == 0)
{
MResourceImp child = {};
child.mName = mName.size();
copy(p->begin(), p->end(), back_inserter(mName));
mName.push_back(0);
mIndex[node].mChild = mIndex.size();
mIndex.push_back(child);
node = mIndex[node].mChild;
continue;
}
// lookup the path element in the current directory
uint32 next = mIndex[node].mChild;
for (;;)
{
const char* name = &mName[0] + mIndex[next].mName;
// if this is the one we're looking for, break out of the loop
if (*p == name)
{
node = next;
break;
}
// if there is a next element, loop
if (mIndex[next].mNext != 0)
{
next = mIndex[next].mNext;
continue;
}
// not found, create it
MResourceImp n = {};
n.mName = mName.size();
copy(p->begin(), p->end(), back_inserter(mName));
mName.push_back(0);
node = mIndex.size();
mIndex[next].mNext = node;
mIndex.push_back(n);
break;
}
}
assert(node != 0);
assert(node < mIndex.size());
mIndex[node].mSize = inSize;
mIndex[node].mData = mData.size();
copy(inData, inData + inSize, back_inserter(mData));
while ((mData.size() % 8) != 0)
mData.push_back('\0');
}