示例#1
0
    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
0
 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());
 }
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
0
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
0
 ostream::string path_to_stream(fs::path const& path)
 {
     return path.native();
 }
示例#6
0
inline bool PathEq(fs::path const& LHS, fs::path const& RHS) {
  return LHS.native() == RHS.native();
}
示例#7
0
// Testing the allocation behavior of the code_cvt functions requires
// *knowing* that the allocation was not done by "path::__str_".
// This hack forces path to allocate enough memory.
inline void PathReserve(fs::path& p, std::size_t N) {
  auto const& native_ref = p.native();
  const_cast<std::string&>(native_ref).reserve(N);
}
示例#8
0
std::string
C::filename (fs::path const &fn)
{
  return filename (fn.native ());
}