当前位置: 首页>>代码示例>>C++>>正文


C++ path::is_absolute方法代码示例

本文整理汇总了C++中boost::filesystem::path::is_absolute方法的典型用法代码示例。如果您正苦于以下问题:C++ path::is_absolute方法的具体用法?C++ path::is_absolute怎么用?C++ path::is_absolute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在boost::filesystem::path的用法示例。


在下文中一共展示了path::is_absolute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: lib_path_equal

inline bool lib_path_equal(const boost::filesystem::path& lhs, const boost::filesystem::path& rhs) {
    // ./b2 may create symlinks. We assume that there are no two files with same names,
    // si if `lhs.filename() == rhs.filename()` then paths are same.
    const bool res = (lhs.filename() == rhs.filename() && lhs.is_absolute() && rhs.is_absolute());
    if (!res) {
        std::cerr << "lhs != rhs: " << lhs << " != " << rhs << '\n';
    }
    return res;
}
开发者ID:piyooshm,项目名称:Boost.DLL,代码行数:9,代码来源:shared_library_load_test.cpp

示例2: dir

boost::filesystem::path make_relative_path( const boost::filesystem::path& p,
                                            const boost::filesystem::path& from)
{
    RAMEN_ASSERT( p.is_absolute());
    RAMEN_ASSERT( from.is_absolute());

    QDir dir( QString( file_cstring( from)));
    QString fname( QString( file_cstring( p)));
    QString rel_path( dir.relativeFilePath( fname));
    return boost::filesystem::path( rel_path.toStdString());
}
开发者ID:devernay,项目名称:ramen-1,代码行数:11,代码来源:path.cpp

示例3: add_test_file

void tester_util::add_test_file(const problem::single::process::File &file,
                                const test::storage::test &test,
                                const boost::filesystem::path &destination,
                                const unistd::access::Id &owner_id,
                                const mode_t mask) {
  try {
    BOOST_ASSERT(destination.is_absolute());
    if (m_solution_files.find(file.id()) != m_solution_files.end()) {
      BOOST_THROW_EXCEPTION(error() << error::message("Duplicate file ids."));
    }
    // note: strip to filename
    const boost::filesystem::path location = m_solution_files[file.id()] =
        destination / (file.has_path()
                           ? bacs::file::path_cast(file.path()).filename()
                           : boost::filesystem::unique_path());
    m_container_solution_files[file.id()] =
        m_container->filesystem().keepInRoot(location);
    const mode_t mode = file::mode(file.permission()) & mask;
    if (file.init().empty()) {
      touch_test_file(location, owner_id, mode);
    } else {
      copy_test_file(test, file.init(), location, owner_id, mode);
    }
    if (file.has_receive())
      m_receive.push_back({file.id(), location, file.receive()});
  } catch (std::exception &) {
    BOOST_THROW_EXCEPTION(add_test_file_error()
                          << bunsan::enable_nested_current());
  }
}
开发者ID:bacsorg,项目名称:system_single,代码行数:30,代码来源:tester_util.cpp

示例4: ASSERT

optional<unique_ref<fspp::Node>> CryDevice::Load(const bf::path &path) {
  // TODO Split into smaller functions
  ASSERT(path.is_absolute(), "Non absolute path given");

  callFsActionCallbacks();

  if (path.parent_path().empty()) {
    //We are asked to load the base directory '/'.
    return optional<unique_ref<fspp::Node>>(make_unique_ref<CryDir>(this, none, none, _rootKey));
  }

  auto parentWithGrandparent = LoadDirBlobWithParent(path.parent_path());
  auto parent = std::move(parentWithGrandparent.blob);
  auto grandparent = std::move(parentWithGrandparent.parent);

  auto optEntry = parent->GetChild(path.filename().native());
  if (optEntry == boost::none) {
    return boost::none;
  }
  const auto &entry = *optEntry;

  switch(entry.type()) {
    case fspp::Dir::EntryType::DIR:
      return optional<unique_ref<fspp::Node>>(make_unique_ref<CryDir>(this, std::move(parent), std::move(grandparent), entry.key()));
    case fspp::Dir::EntryType::FILE:
      return optional<unique_ref<fspp::Node>>(make_unique_ref<CryFile>(this, std::move(parent), std::move(grandparent), entry.key()));
    case  fspp::Dir::EntryType::SYMLINK:
	  return optional<unique_ref<fspp::Node>>(make_unique_ref<CrySymlink>(this, std::move(parent), std::move(grandparent), entry.key()));
  }
  ASSERT(false, "Switch/case not exhaustive");
}
开发者ID:cryfs,项目名称:cryfs,代码行数:31,代码来源:CryDevice.cpp

示例5: contains

bool DiskCacheTranslator::contains(const boost::filesystem::path& keypath) const
{
    boost::system::error_code error;
    if(keypath.is_absolute())
        return boost::filesystem::exists(keypath, error);
    return boost::filesystem::exists(relativePathToAbsolutePath(keypath), error);
}
开发者ID:aoblet,项目名称:TuttleOFX,代码行数:7,代码来源:DiskCacheTranslator.cpp

示例6: make_rooted_path

FS::path ConfdUnittestHarness::make_rooted_path(
  FS::path filename)
{
  try {
    // Can handle $RIFT_ROOT
    std::string raw_fullpath = filename.native();
    const char RIFT_ROOT[] = "$RIFT_ROOT";
    if (raw_fullpath.substr(0, sizeof(RIFT_ROOT)-1) == RIFT_ROOT) {
      raw_fullpath.replace(0, sizeof(RIFT_ROOT)-1, rift_root_.c_str());
    }

    FS::path fullpath = raw_fullpath;
    if (!fullpath.is_absolute()) {
      fullpath = cwd_/fullpath;
    }
    return fullpath;

  } catch (const FS::filesystem_error& fe) {
    cerr << "Filesystem error: " << fe.what()
         << ": " << fe.path1()
         << ", " << fe.path2()
         << std::endl;
    throw std::exception(); // don't rethrow, to prevent being recaught by harness
  }
}
开发者ID:gonotes,项目名称:RIFT.ware,代码行数:25,代码来源:rw_ut_confd.cpp

示例7: conf_load

void ConfdUnittestHarness::conf_load(
  FS::path filename)
{
  try {
    if (!filename.is_absolute()) {
      filename = cwd_/filename;
    }

    if (!exists(filename)) {
      cerr << "Could not find harness configuration " << filename << std::endl;
      throw std::exception();
    }

    confd_conf_dom_ = std::move(xml_mgr_->create_document_from_file(filename.c_str(), false/*validate*/));
    if (!confd_conf_dom_.get()) {
      cerr << "Failed to load configuration " << filename << std::endl;
      throw std::exception();
    }

  } catch (const FS::filesystem_error& fe) {
    cerr << "Filesystem error: " << fe.what()
         << ": " << fe.path1()
         << ", " << fe.path2()
         << std::endl;
    throw std::exception(); // don't rethrow, to prevent being recaught by harness
  }
}
开发者ID:gonotes,项目名称:RIFT.ware,代码行数:27,代码来源:rw_ut_confd.cpp

示例8: catch

void repository::cache::verify_and_repair_directory(
    const boost::filesystem::path &path) {
  try {
    if (!path.is_absolute())
      BOOST_THROW_EXCEPTION(
          invalid_configuration_relative_path_error()
          << invalid_configuration_relative_path_error::path(path));
    BUNSAN_LOG_TRACE << "Checking " << path;
    if (!boost::filesystem::is_directory(path)) {
      if (!boost::filesystem::exists(path)) {
        BUNSAN_LOG_ERROR << "Directory " << path << " was not found";
      } else {
        BUNSAN_LOG_ERROR << path
                         << " is not a directory: starting recursive remove";
        boost::filesystem::remove_all(path);
      }
      if (boost::filesystem::create_directory(path))
        BUNSAN_LOG_TRACE << "Created missing " << path << " directory";
    }
  } catch (std::exception &) {
    BOOST_THROW_EXCEPTION(cache_verify_and_repair_directory_error()
                          << cache_verify_and_repair_directory_error::path(path)
                          << enable_nested_current());
  }
}
开发者ID:bunsanorg,项目名称:pm,代码行数:25,代码来源:cache.cpp

示例9: relative

	boost::filesystem::path relative(boost::filesystem::path basefile, boost::filesystem::path path)
	{
		if (path.is_absolute()) {
			return path;
		}

		return basefile.parent_path() / path;
	}
开发者ID:simonlmn,项目名称:actracktive,代码行数:8,代码来源:Filesystem.cpp

示例10: find_exe_path

fs::path find_exe_path(const fs::path& argv0)
{
    /*
      Linux: readlink /proc/self/exe
      FreeBSD: sysctl CTL_KERN KERN_PROC KERN_PROC_PATHNAME -1

      Mac OS X: _NSGetExecutablePath() (man 3 dyld)
      Solaris: getexecname()
      BSD with procfs: readlink /proc/curproc/file
      Windows: GetModuleFileName() with hModule = NULL
    */

    /* For Mac
       char path[1024];
       uint32_t size = sizeof(path);
       if (_NSGetExecutablePath(path, &size) == 0)
         printf("executable path is %s\n", path);
       else
         printf("buffer too small; need size %u\n", size);
    */
    fs::path program_location;

    // This only works on Linux.
    if (fs::exists("/proc/self/exe"))
        program_location = "/proc/self/exe";
    // This only works on BSD with procfs.
    else if (fs::exists("/proc/curproc/file"))
        program_location = "/proc/curproc/file";
    // Try argv[0] - This *PROBABLY* works on windows.
    else if (fs::exists(argv0))
        program_location = argv0;
    // Search $PATH for argv[0]
    else if (not argv0.is_absolute() and getenv("PATH"))
    {
        string PATH = getenv("PATH");
        vector<string> paths = split(PATH,':');
        for(const string& prefix: paths)
        {
            fs::path p = prefix / argv0;
            if (fs::exists(p))
                program_location = p;
        }
    }
    program_location = canonical(program_location);
    program_location.remove_filename();

    return program_location;
}
开发者ID:,项目名称:,代码行数:48,代码来源:

示例11: toEnum

// TEXTURE2D
vgd::Shp< vgd::node::Texture2D > createTexture2D(	const vgio::Media & media, const boost::filesystem::path pathFilename, const int index, const aiString aiImagePath,
													const aiTextureMapMode mapU, const aiTextureMapMode mapV )
{
	// Compute image path
	std::string imagePathFilenameStr;

	namespace bfs = boost::filesystem;
	const bfs::path imagePathFilename = aiImagePath.C_Str();

	if ( imagePathFilename.is_absolute() )
	{
		imagePathFilenameStr = imagePathFilename.string();
	}
	else // relative path
	{
		const bfs::path rootPath = pathFilename.parent_path();

		imagePathFilenameStr = (rootPath / imagePathFilename).string();
	}

	// Texture node
	using vgd::node::Texture2D;
	vgd::Shp< Texture2D > texture = Texture2D::create( imagePathFilename.filename().string(), (int8)index );

	// IMAGE
	// Gathers the image from the cache.
	vgd::Shp< vgd::basic::IImage > image;
	image = vgio::ImageCache::load( media, imagePathFilenameStr );
	texture->setImage( image );

	// Default values
	texture->setMipmap( true );
	texture->setMinFilter( Texture2D::LINEAR_MIPMAP_LINEAR );
	texture->setMagFilter( Texture2D::LINEAR );

	// WRAPPING
	texture->setWrapS( toEnum(mapU) );
	texture->setWrapT( toEnum(mapV) );

	// FUNCTION
	texture->sethFunction( vgd::node::Texture2D::FUN_MODULATE ); // @todo
	return texture;
}
开发者ID:npapier,项目名称:vgsdk,代码行数:44,代码来源:Loader.cpp

示例12: A

TEST_F(PathTest, absolutism)
{
#define A(p)                                    \
    fs::path(p).is_absolute()

    EXPECT_TRUE(A("/"));
    EXPECT_FALSE(A("."));
    EXPECT_FALSE(A(".."));
    EXPECT_FALSE(A("./"));
    EXPECT_FALSE(A("../"));
    EXPECT_TRUE(A("/."));
    EXPECT_TRUE(A("/.."));
    EXPECT_TRUE(A("/foo/../"));
    EXPECT_TRUE(A("/foo/./"));
    EXPECT_TRUE(A("/foo/.."));

#undef A

    const fs::path empty(fs::path("/").parent_path());
    EXPECT_FALSE(empty.is_absolute());
}
开发者ID:DarumasLegs,项目名称:volumedriver,代码行数:21,代码来源:PathTest.cpp

示例13: system_complete

  static boost::filesystem::path system_absolute(
      const boost::filesystem::path path)
  {
    if (path.empty())
      return path;

    if (path.is_absolute())
      return path;

    if (path.has_parent_path())
      return bfs::system_complete(path);

    if (!bfs::exists(path) || bfs::is_directory(path))
    {
      std::string envPath = qi::os::getenv("PATH");
      size_t begin = 0;
#ifndef _WIN32
      static const char SEPARATOR = ':';
#else
      static const char SEPARATOR = ';';
#endif
      for (size_t end = envPath.find(SEPARATOR, begin);
          end != std::string::npos;
          begin = end + 1, end = envPath.find(SEPARATOR, begin))
      {
        std::string realPath = envPath.substr(begin, end - begin);
        bfs::path p(realPath);

        p /= path;
        p = boost::filesystem::system_complete(p);

        if (boost::filesystem::exists(p) &&
            !boost::filesystem::is_directory(p))
          return p.string(qi::unicodeFacet());
      }
    }

    // fallback to something
    return bfs::system_complete(path);
  }
开发者ID:soshiant1992,项目名称:libqi,代码行数:40,代码来源:application.cpp

示例14: isAbsolute

bool FileSourceProvider::isAbsolute(const boost::filesystem::path& file)
{
    return file.is_absolute();
}
开发者ID:ggeorgiev,项目名称:compil,代码行数:4,代码来源:file_source_provider.cpp

示例15: checkAbsolute

bool checkAbsolute(const boost::filesystem::path& path)
{
    return path.is_absolute();
}
开发者ID:kayusawa,项目名称:choreonoid,代码行数:4,代码来源:FileUtil.cpp


注:本文中的boost::filesystem::path::is_absolute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。