本文整理汇总了C++中fs::path::native方法的典型用法代码示例。如果您正苦于以下问题:C++ path::native方法的具体用法?C++ path::native怎么用?C++ path::native使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fs::path
的用法示例。
在下文中一共展示了path::native方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: path_to_stream
ostream::string path_to_stream(fs::path const& path)
{
cygwin_conv_path_t flags = CCP_WIN_W_TO_POSIX | CCP_RELATIVE;
ssize_t size = cygwin_conv_path(flags, path.native().c_str(), NULL, 0);
if (size < 0)
throw conversion_error("Error converting windows path to cygwin.");
boost::scoped_array<char> result(new char[size]);
if(cygwin_conv_path(flags, path.native().c_str(), result.get(), size))
throw conversion_error("Error converting windows path to cygwin.");
return std::string(result.get());
}
示例2: make_cmake_cmd
std::wstring make_cmake_cmd(const fs::path& cmake_exe,
const fs::path& cmake_script,
const std::vector<CMakeVariable>& pass_variables)
{
std::wstring cmd_cmake_pass_variables = Strings::join(L" ", pass_variables, [](auto&& v) { return v.s; });
return Strings::wformat(
LR"("%s" %s -P "%s")", cmake_exe.native(), cmd_cmake_pass_variables, cmake_script.generic_wstring());
}
示例3: apk_path
std::vector<std::string> filestorage::get_file_list(const boost::filesystem::path &path) {
std::vector<std::string> file_list;
if (!path.empty()) {
fs::path apk_path(path);
fs::recursive_directory_iterator end;
for (fs::recursive_directory_iterator i(apk_path); i != end; ++i) {
const fs::path cp = (*i);
std::string filename = extract_filename(cp.native());
file_list.push_back(filename);
}
}
return file_list;
}
示例4: main
int main() {
// clang-format off
struct {
std::string input;
std::string expect;
} TestCases[] = {
{"", fs::current_path()},
{".", fs::current_path()},
{"/", "/"},
{"/foo", "/foo"},
{"/.", "/"},
{"/./", "/"},
{"a/b", fs::current_path() / "a/b"},
{"a", fs::current_path() / "a"},
{"a/b/", fs::current_path() / "a/b/"},
{StaticEnv::File, StaticEnv::File},
{StaticEnv::Dir, StaticEnv::Dir},
{StaticEnv::SymlinkToDir, StaticEnv::Dir},
{StaticEnv::SymlinkToDir / "dir2/.", StaticEnv::Dir / "dir2"},
// FIXME? If the trailing separator occurs in a part of the path that exists,
// it is ommitted. Otherwise it is added to the end of the result.
{StaticEnv::SymlinkToDir / "dir2/./", StaticEnv::Dir / "dir2"},
{StaticEnv::SymlinkToDir / "dir2/DNE/./", StaticEnv::Dir / "dir2/DNE/"},
{StaticEnv::SymlinkToDir / "dir2", StaticEnv::Dir2},
{StaticEnv::SymlinkToDir / "dir2/../dir2/DNE/..", StaticEnv::Dir2 / ""},
{StaticEnv::SymlinkToDir / "dir2/dir3/../DNE/DNE2", StaticEnv::Dir2 / "DNE/DNE2"},
{StaticEnv::Dir / "../dir1", StaticEnv::Dir},
{StaticEnv::Dir / "./.", StaticEnv::Dir},
{StaticEnv::Dir / "DNE/../foo", StaticEnv::Dir / "foo"}
};
// clang-format on
int ID = 0;
bool Failed = false;
for (auto& TC : TestCases) {
++ID;
fs::path p(TC.input);
const fs::path output = fs::weakly_canonical(p);
if (!PathEq(output, TC.expect)) {
Failed = true;
std::cerr << "TEST CASE #" << ID << " FAILED: \n";
std::cerr << " Input: '" << TC.input << "'\n";
std::cerr << " Expected: '" << TC.expect << "'\n";
std::cerr << " Output: '" << output.native() << "'";
std::cerr << std::endl;
}
}
return Failed;
}
示例5: filename
std::string
C::filename (fs::path const &fn)
{
return filename (fn.native ());
}