Пример #1
0
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");
}
Пример #2
0
void getResourceDirPath(boost::filesystem::path& path)
{

#if defined(SQUIDGE_PLATFORM_MACOSX)
   // Executable location is at 'Squidge.app/Contents/MacOS/Squidge'
   // Resource directory is at 'Squidge.app/Contents/Resources'

   getExecutablePath(path);
   path = path.parent_path().parent_path();
   path /= "Resources";
   path = canonical(path);

#elif defined(SQUIDGE_PLATFORM_WINDOWS)
   // Executable location is at '.../Squidge.exe'
   // Resource directory is at '.../Resources'

   getExecutablePath(path);
   path = path.parent_path();
   path /= "Resources";
   path = canonical(path);

#else

   #error No impl of getResourceDirPath on this platform!

#endif

}
void ImageReaderWriterTest::checkSaveLoadInr( ::fwData::Image::sptr image )
{
    // inr only support image origin (0,0,0)
    ::fwData::Image::OriginType origin(3,0);
    image->setOrigin(origin);

    // save image in inr
    const ::boost::filesystem::path PATH = "imageInrTest/image.inr.gz";
    ::boost::filesystem::create_directories( PATH.parent_path() );
    ::fwItkIO::ImageWriter::sptr myWriter = ::fwItkIO::ImageWriter::New();
    myWriter->setObject(image);
    myWriter->setFile(PATH);
    myWriter->write();

    // load Image
    ::fwData::Image::sptr image2 = ::fwData::Image::New();
    ::fwItkIO::ImageReader::sptr myReader = ::fwItkIO::ImageReader::New();
    myReader->setObject(image2);
    myReader->setFile(PATH);
    myReader->read();

    ::boost::filesystem::remove_all( PATH.parent_path().string() );

    ::fwItkIO::ut::helper::roundSpacing(image2);


    ::fwTest::helper::ExcludeSetType exclude;
    exclude.insert("window_center");
    exclude.insert("window_width");
    // check Image
    // inr only support float spacing and float origin => add tolerance for comparison (+/-0.00001)
    CPPUNIT_ASSERT(::fwTest::helper::compare(image, image2, exclude));
}
Пример #4
0
CLogger::CLogger(const std::string& name,
                 const boost::filesystem::path& logFilePath)
    : m_name(name)
{
    if (!boost::filesystem::exists(logFilePath.parent_path()))
        boost::filesystem::create_directories(logFilePath.parent_path());
    m_logFile.open(logFilePath.string(), std::ofstream::out | std::ofstream::app);
}
Пример #5
0
int main()
{
    boost::filesystem::path const this_source_file = __FILE__;
    boost::filesystem::path const test_includes_root =
        this_source_file.parent_path();
    boost::filesystem::path const sources_root = test_includes_root / "sources";
    boost::filesystem::path const headers_root =
        test_includes_root.parent_path() / "silicium";
    std::string const linux_system_name = "linux";
    std::string const windows_system_name = "win32";
    std::string const current_system_name =
#ifdef _WIN32
        windows_system_name
#else
        linux_system_name
#endif
        ;
    std::unordered_set<std::string> blacklist;
    blacklist.insert(windows_system_name);
    blacklist.insert(linux_system_name);
#ifdef _WIN32
    blacklist.insert("posix");
#endif
    blacklist.erase(current_system_name);
    blacklist.insert("delegator");
    auto const is_relevant_directory =
        [&blacklist](boost::filesystem::path const &dir)
    {
        return blacklist.count(dir.leaf().string()) == 0;
    };

    std::set<std::string> all_headers;
    auto const add_header = [&all_headers](std::string const &header_name)
    {
        // sort the headers by name for a deterministic ordering
        all_headers.insert(header_name);
    };
    generate_sources_recursively(
        sources_root, headers_root, "", is_relevant_directory, add_header);

    auto const all_headers_file_name =
        sources_root / current_system_name / "_all_headers_.cpp";
    std::ofstream all_headers_file(all_headers_file_name.string());
    if (!all_headers_file)
    {
        throw std::runtime_error("Cannot open file " +
                                 all_headers_file_name.string());
    }
    for (std::string const &header_name : all_headers)
    {
        all_headers_file << "#include " << header_name << '\n';
    }
}
Пример #6
0
TEST (PCL, Outofcore_Octree_Build)
{

  boost::filesystem::remove_all (filename_otreeA.parent_path ());
  boost::filesystem::remove_all (filename_otreeB.parent_path ());

  Eigen::Vector3d min (-32.0, -32.0, -32.0);
  Eigen::Vector3d max (32.0, 32.0, 32.0);
  
  // Build two trees using each constructor
  // depth of treeA will be same as B because 1/2^3 > .1 and 1/2^4 < .1
  // depth really affects performance
  octree_disk treeA (min, max, .1, filename_otreeA, "ECEF");
  octree_disk treeB (4, min, max, filename_otreeB, "ECEF");

  // Equidistributed uniform pseudo-random number generator
  boost::mt19937 rng(rngseed);

  // For testing sparse 
  //boost::uniform_real<double> dist(0,1);

  // For testing less sparse
  boost::normal_distribution<float> dist (0.5f, .1f);

  // Create a point
  PointT p;
  points.resize (numPts);

  //ignore these fields from the UR point for now
  // p.r = p.g = p.b = 0;
  // p.nx = p.ny = p.nz = 1;
  // p.cameraCount = 0;
  // p.error = 0;
  // p.triadID = 0;

  // Radomize it's position in space
  for (size_t i = 0; i < numPts; i++)
  {
    p.x = dist (rng);
    p.y = dist (rng);
    p.z = dist (rng);

    points[i] = p;
  }

  // Add to tree
  treeA.addDataToLeaf (points);

  // Add to tree
  treeB.addDataToLeaf (points);

}
Пример #7
0
    void cleanUpFilesystem ()
    {
      //clear existing trees from test path

      boost::filesystem::remove_all (filename_otreeA.parent_path ());
      boost::filesystem::remove_all (filename_otreeB.parent_path ());

      boost::filesystem::remove_all (filename_otreeA_LOD.parent_path ());
      boost::filesystem::remove_all (filename_otreeB_LOD.parent_path ());

      boost::filesystem::remove_all (outofcore_path.parent_path ());

    }
Пример #8
0
inline Status listInAbsoluteDirectory(const fs::path& path,
                                      std::vector<std::string>& results,
                                      GlobLimits limits) {
  if (path.filename() == "*" && !pathExists(path.parent_path())) {
    return Status(1, "Directory not found: " + path.parent_path().string());
  }

  if (path.filename() == "*" && !isDirectory(path.parent_path())) {
    return Status(1, "Path not a directory: " + path.parent_path().string());
  }

  genGlobs(path.string(), results, limits);
  return Status(0, "OK");
}
Пример #9
0
TEST (PCL, Outofcore_Octree_Build_LOD)
{

  boost::filesystem::remove_all (filename_otreeA_LOD.parent_path ());
  boost::filesystem::remove_all (filename_otreeB_LOD.parent_path ());

  Eigen::Vector3d min (0.0, 0.0, 0.0);
  Eigen::Vector3d max (1.0, 1.0, 1.0);
  
  // Build two trees using each constructor
  octree_disk treeA (min, max, .1, filename_otreeA_LOD, "ECEF");
  octree_disk treeB (4, min, max, filename_otreeB_LOD, "ECEF");

  // Equidistributed uniform pseudo-random number generator
  boost::mt19937 rng (rngseed);
  // For testing sparse
  //boost::uniform_real<double> dist(0,1);
  // For testing less sparse
  boost::normal_distribution<float> dist (0.5f, .1f);

  // Create a point
  PointT p;

/*
  p.r = p.g = p.b = 0;
  p.nx = p.ny = p.nz = 1;
  p.cameraCount = 0;
  p.error = 0;
  p.triadID = 0;
*/
  points.resize (numPts);

  // Radomize it's position in space
  for (size_t i = 0; i < numPts; i++)
  {
    p.x = dist (rng);
    p.y = dist (rng);
    p.z = dist (rng);
    
    points[i] = p;
  }

  // Add to tree
  treeA.addDataToLeaf_and_genLOD (points);

  // Add to tree
  treeB.addDataToLeaf_and_genLOD (points);
}
Пример #10
0
bool RLogMill::findRepository(boost::filesystem::path& dir, std::string& log_format) {

    dir = absolute(dir);

    //fprintf(stderr, "find repository from initial path: %s\n", dir.string().c_str());

    while(is_directory(dir)) {

             if(is_directory(dir / ".git")) log_format = "git";
        else if(is_directory(dir / ".hg"))  log_format = "hg";
        else if(is_directory(dir / ".bzr")) log_format = "bzr";
        else if(is_directory(dir / ".svn")) log_format = "svn";

        if(!log_format.empty()) {
            //fprintf(stderr, "found '%s' repository at: %s\n", log_format.c_str(), dir.string().c_str());
            return true;
        }

        if(!dir.has_parent_path()) return false;

        dir = dir.parent_path();
    }

    return false;
}
Пример #11
0
boost::filesystem::path readlink(const boost::filesystem::path&
#ifndef BOOST_WINDOWS_API
		path
#endif
		)
{
#ifdef BOOST_WINDOWS_API
	throw std::runtime_error("readlink() not implemented on Windows");
#else
	string link(path.external_file_string());
	vector<char> buf(512);

	for (;;)
	{
		const ssize_t len = readlink(link.c_str(), &buf[0], buf.size());
		if (len == -1)
		{
			if (errno == ENAMETOOLONG)
			{
				buf.resize(2 * buf.size());
				continue;
			}

			throw system_error(error_code(errno, get_system_category()));
		}

		return path.parent_path() / string(&buf[0], len);
	}
#endif
}
Пример #12
0
void File::create() const {
  const boost::filesystem::path abs = boost::filesystem::absolute(path);
  const boost::filesystem::path dir = abs.parent_path();
  createDirectories(dir);
  mknod();
  chown();
}
Пример #13
0
void CryNode::rename(const bf::path &to) {
  device()->callFsActionCallbacks();
  if (_parent == none) {
    //We are the root direcory.
    throw FuseErrnoException(EBUSY);
  }
  auto targetDirWithParent = _device->LoadDirBlobWithParent(to.parent_path());
  auto targetDir = std::move(targetDirWithParent.blob);
  auto targetDirParent = std::move(targetDirWithParent.parent);

  auto old = (*_parent)->GetChild(_key);
  if (old == boost::none) {
    throw FuseErrnoException(EIO);
  }
  fsblobstore::DirEntry oldEntry = *old; // Copying this (instead of only keeping the reference) is necessary, because the operations below (i.e. RenameChild()) might make a reference invalid.
  auto onOverwritten = [this] (const blockstore::Key &key) {
      device()->RemoveBlob(key);
  };
  _updateParentModificationTimestamp();
  if (targetDir->key() == (*_parent)->key()) {
    targetDir->RenameChild(oldEntry.key(), to.filename().native(), onOverwritten);
  } else {
    _updateTargetDirModificationTimestamp(*targetDir, std::move(targetDirParent));
    targetDir->AddOrOverwriteChild(to.filename().native(), oldEntry.key(), oldEntry.type(), oldEntry.mode(), oldEntry.uid(), oldEntry.gid(),
                                   oldEntry.lastAccessTime(), oldEntry.lastModificationTime(), onOverwritten);
    (*_parent)->RemoveChild(oldEntry.name());
    // targetDir is now the new parent for this node. Adapt to it, so we can call further operations on this node object.
    _parent = cpputils::to_unique_ptr(std::move(targetDir));
  }
}
Пример #14
0
bool ZipArchive::extract(boost::filesystem::path from, boost::filesystem::path where, std::vector<std::string> what)
{
	unzFile archive = unzOpen2_64(from.c_str(), FileStream::GetMinizipFilefunc());

	auto onExit = vstd::makeScopeGuard([&]()
	{
		unzClose(archive);
	});

	for (const std::string & file : what)
	{
		if (unzLocateFile(archive, file.c_str(), 1) != UNZ_OK)
			return false;

		const boost::filesystem::path fullName = where / file;
		const boost::filesystem::path fullPath = fullName.parent_path();

		boost::filesystem::create_directories(fullPath);
		// directory. No file to extract
		// TODO: better way to detect directory? Probably check return value of unzOpenCurrentFile?
		if (boost::algorithm::ends_with(file, "/"))
			continue;

		FileStream destFile(fullName, std::ios::out | std::ios::binary);
		if (!destFile.good())
			return false;

		if (!extractCurrent(archive, destFile))
			return false;
	}
	return true;
}
Пример #15
0
int FilesystemImpl::createAndOpenFile(const bf::path &path, mode_t mode, uid_t uid, gid_t gid) {
  PROFILE(_createAndOpenFileNanosec);
  auto dir = LoadDir(path.parent_path());
  PROFILE(_createAndOpenFileNanosec_withoutLoading);
  auto file = dir->createAndOpenFile(path.filename().native(), mode, uid, gid);
  return _open_files.open(std::move(file));
}
Пример #16
0
static std::string
loadFile (boost::property_tree::ptree &config,
          const boost::filesystem::path &file)
{
  boost::filesystem::path extension = file.extension();
  boost::filesystem::path extension2 = file.stem().extension();
  std::string fileName = file.filename().string();
  boost::property_tree::ptree readConfig;

  if (extension2.string() == ".conf") {
    if (extension.string() == ".json") {
      boost::property_tree::read_json (file.string(), readConfig);
    } else if (extension.string() == ".info") {
      boost::property_tree::read_info (file.string(), readConfig);
    } else if (extension.string() == ".ini") {
      boost::property_tree::read_ini (file.string(), readConfig);
    } else if (extension.string() == ".xml") {
      boost::property_tree::read_xml (file.string(), readConfig);
    } else {
      throw ParseException ("Unknonw file format");
    }
  } else {
    throw ParseException ("Unknonw file format");
  }

  mergePropertyTrees (config, readConfig);

  config.put ("configPath", file.parent_path().string() );

  fileName = fileName.substr (0, fileName.size() - extension.string().size() );
  fileName = fileName.substr (0, fileName.size() - extension2.string().size() );

  return fileName;
}
Пример #17
0
bool SOpenCVWriter::defineLocationGUI()
{
    bool ok = false;

    // Ask user for the file path
    static ::boost::filesystem::path _sDefaultPath;

    ::fwGui::dialog::LocationDialog dialogFile;
    dialogFile.setTitle(m_windowTitle.empty() ? "Enter file name" : m_windowTitle);
    dialogFile.setDefaultLocation( ::fwData::location::Folder::New(_sDefaultPath) );
    dialogFile.setOption(::fwGui::dialog::ILocationDialog::WRITE);
    dialogFile.setType(::fwGui::dialog::ILocationDialog::SINGLE_FILE);
    dialogFile.addFilter("XML file", "*.xml");
    dialogFile.addFilter("YAML file", "*.yaml *.yml");

    ::fwData::location::SingleFile::sptr result
        = ::fwData::location::SingleFile::dynamicCast( dialogFile.show() );

    if (result)
    {
        _sDefaultPath = result->getPath();
        this->setFile( _sDefaultPath );
        dialogFile.saveDefaultLocation( ::fwData::location::Folder::New(_sDefaultPath.parent_path()) );
        ok = true;
    }
    else
    {
        this->clearLocations();
    }

    return ok;
}
Пример #18
0
AppState::AppState(const boost::filesystem::path& filePath)
    : m_path(filePath), m_recentDocumentsNode(0),
    m_recentWorkspacesNode(0)
{
    bool saveNeeded = false;
    if (boost::filesystem::exists(filePath))
    {
        m_document.load_file(filePath.string().c_str());
        m_recentDocumentsNode = m_document.child(rootElementName).child(recentDocumentsElementName);
        m_recentDocuments.load(m_recentDocumentsNode);
        m_recentWorkspacesNode = m_document.child(rootElementName).child(recentWorkspacesElementName);
        m_recentWorkspaces.load(m_recentWorkspacesNode);
    }
    else
    {
        boost::filesystem::create_directories(filePath.parent_path());

        saveNeeded = true;
        pugi::xml_node rootNode = m_document.append_child(rootElementName);
        if (rootNode)
        {
            m_recentDocumentsNode = rootNode.append_child(recentDocumentsElementName);
            m_recentWorkspacesNode = rootNode.append_child(recentWorkspacesElementName);
        }
    }

    if (saveNeeded)
    {
        save();
    }
}
Пример #19
0
	fl::configuration get_freelan_configuration(const fscp::logger& logger, const service_configuration& configuration)
	{
		namespace po = boost::program_options;

		po::options_description configuration_options("Configuration");
		configuration_options.add(get_server_options());
		configuration_options.add(get_client_options());
		configuration_options.add(get_fscp_options());
		configuration_options.add(get_security_options());
		configuration_options.add(get_tap_adapter_options());
		configuration_options.add(get_switch_options());
		configuration_options.add(get_router_options());

		fl::configuration fl_configuration;
		po::variables_map vm;
		const fs::path configuration_file = configuration.configuration_file;
		const fs::path root_directory = configuration_file.parent_path();
		fs::basic_ifstream<char> ifs(configuration_file);

		if (!ifs)
		{
			throw po::reading_file(configuration_file.string().c_str());
		}

		po::store(po::parse_config_file(ifs, configuration_options, true), vm);
		make_paths_absolute(vm, root_directory);
		po::notify(vm);

		setup_configuration(logger, fl_configuration, vm);

		return fl_configuration;
	}
Пример #20
0
void try_run_file(const boost::filesystem::path & cur)
{
	if(cur.extension().native().compare(".py"))
	{
		return;
	}

	script_file_parser script_file(cur.native());

	if(script_file.is_valid())
	{
		boost::filesystem::path work, out;
		create_directories(cur, work, out);

		auto parent = cur.parent_path();
		auto start  = parent.begin();

		for(auto p = config::tests.begin(); p != config::tests.end() && *p == *start; ++p, ++start) ;

		for(; start != parent.end(); ++start)
		{
			script_file.add_keyword((*start).native());
		}

		script_file.add_title(cur.stem().native());

		if(config::query->evaluate(script_file))
		{
			script_scheduler()->schedule_file(cur, work, out);
		}
	}
}
Пример #21
0
void create_directories(const boost::filesystem::path & cur, 
						      boost::filesystem::path & work,
							  boost::filesystem::path & out)
{
	auto parent = cur.parent_path();
	auto start  = parent.begin();

	for(auto p = config::tests.begin(); p != config::tests.end() && *p == *start; ++p, ++start) ;

	work = config::cache;
	out  = config::data;

	for(; start != parent.end(); ++start)
	{
		work /= *start;
		out  /= *start;
		boost::filesystem::create_directory(work);
		boost::filesystem::create_directory(out);
	}

	work /= cur.stem();
	out  /= (cur.stem().native() + ".out");

	boost::filesystem::create_directory(work);
}
Пример #22
0
::fwAtoms::Object::sptr readAttachment( const ::boost::filesystem::path& filePath )
{
    const ::boost::filesystem::path folderPath = filePath.parent_path();
    const ::boost::filesystem::path filename   = filePath.filename();
    const std::string extension                = ::boost::filesystem::extension(filePath);

    ::fwZip::IReadArchive::sptr readArchive;
    ::boost::filesystem::path archiveRootName;
    ::fwAtomsBoostIO::FormatType format = ::fwAtomsBoostIO::UNSPECIFIED;

    if ( extension == ".json" )
    {
        readArchive     = ::fwZip::ReadDirArchive::New(folderPath.string());
        archiveRootName = filename;
        format          = ::fwAtomsBoostIO::JSON;
    }
    else if ( extension == ".jsonz" )
    {
        readArchive     = ::fwZip::ReadZipArchive::New(filePath.string());
        archiveRootName = "root.json";
        format          = ::fwAtomsBoostIO::JSON;
    }
    else
    {
        FW_RAISE( "This file extension '" << extension << "' is not managed" );
    }

    ::fwAtomsBoostIO::Reader reader;
    ::fwAtoms::Object::sptr atom =
        ::fwAtoms::Object::dynamicCast(reader.read(readArchive, archiveRootName, format));

    return atom;
}
Пример #23
0
void writeAttachment( const ::boost::filesystem::path& filePath, const ::fwAtoms::Object::sptr atom )
{
    const ::boost::filesystem::path folderPath = filePath.parent_path();
    const ::boost::filesystem::path filename   = filePath.filename();
    std::string extension                      = ::boost::filesystem::extension(filePath);

    // Write atom
    ::fwZip::IWriteArchive::sptr writeArchive;
    ::fwAtomsBoostIO::FormatType format;
    ::boost::filesystem::path archiveRootName;

    if ( extension == ".json" )
    {
        writeArchive    = ::fwZip::WriteDirArchive::New(folderPath.string());
        archiveRootName = filename;
        format          = ::fwAtomsBoostIO::JSON;
    }
    else if ( extension == ".jsonz" )
    {
        if ( ::boost::filesystem::exists( filePath ) )
        {
            ::boost::filesystem::remove( filePath );
        }
        writeArchive    = ::fwZip::WriteZipArchive::New(filePath.string());
        archiveRootName = "root.json";
        format          = ::fwAtomsBoostIO::JSON;
    }
    else
    {
        FW_RAISE( "This file extension '" << extension << "' is not managed" );
    }

    ::fwAtomsBoostIO::Writer(atom).write( writeArchive, archiveRootName, format );
    writeArchive.reset();
}
Пример #24
0
	OGL4ShaderPtr OGL4ShaderCompiler::CreateShaderFromFile(SHADER_TYPE type, const boost::filesystem::path& path, const std::string& entry)
	{
	
		std::string source = LoadShaderSource(path.string());
		
		
		if(source == "")
		{
			return OGL4ShaderPtr();
		}
		


		std::vector<IncludeInfo> inc_list;
		IncludeInfo inc;
		inc.file = path;
		inc.lines = GetSourceLines(source);

		inc_list.push_back(inc);
		source = ProcessInclude(path.parent_path(), source, inc_list);
		
		inc_list.push_back(inc);
		inc_list.erase(inc_list.begin());


		source = ClearVersionComment(source);

		return CreateShaderFromSource(type, source, inc_list, entry);


	}
Пример #25
0
std::auto_ptr<serialization::yaml_iarchive_t> import_composition( const boost::filesystem::path& p)
{
	composition_t comp;
	comp.set_composition_dir( p.parent_path());
	
    boost::filesystem::ifstream ifs( p, serialization::yaml_iarchive_t::file_open_mode());

    if( !ifs.is_open() || !ifs.good())
		throw std::runtime_error( "Couldn't open file");

	std::auto_ptr<serialization::yaml_iarchive_t> in;
	
    /*
	in.reset( new serialization::yaml_iarchive_t( ifs));
		
	if( !in->read_composition_header())
		throw std::runtime_error( "Bad file header");

	comp.read( *in);

	app().document().composition().deselect_all();
	comp.select_all();

	app().document().composition().merge_composition( comp);
    */
	return in;
}
Пример #26
0
/** Parse OWL ontology file and print triples
*******************************************************************************/
int main(int argc, char* argv[]) {
   bpo::options_description od;
   od.add_options()
            ("help,h", "help message")
            ("input-file", bpo::value<std::string>(), "input OWL file")
            ("include,i",
                     bpo::value<std::vector<std::string> >()->zero_tokens()
                     ->composing(), "search paths")
            ("count,c", "only print the number of triples")
            ;
   bpo::positional_options_description pod;
   pod.add("input-file", -1);
   bpo::variables_map vm;
   store(bpo::command_line_parser(argc, argv).options(od).positional(pod).run(), vm);
   notify(vm);

   if( ! vm.count("input-file") || vm.count("help") ) {
      std::cout
      << "Parse OWL ontology and print triples" << '\n'
      << "Usage:" << '\n'
      << "print_triples [-i[path]] [-c] <OWL_ontology_file.owl>" << '\n'
      << od << '\n';
      return ! vm.count("help");
   }

   owlcpp::Triple_store store;
   const bfs::path in( vm["input-file"].as<std::string>());
   try {
      if( vm.count("include") ) { //load input-file and its includes
         owlcpp::Catalog cat;
         //how far to look into each file for ontologyVersion
         const std::size_t search_depth = 100;
         std::vector<std::string> const& vin = vm["include"].as<std::vector<std::string> >();
         if( vin.empty() ) {
            add(cat, in.parent_path(), true, search_depth);
         } else {
            BOOST_FOREACH(std::string const& p, vin) add(cat, p, true, search_depth);
         }
         load_file(in, store, cat);
      } else { //load just input-file
         load_file(in, store);
      }
      if( vm.count("count") ) {
         std::cout
         << store.map_triple().size() << " triples" << '\n'
         << store.map_node().size() << " nodes" << '\n'
         << store.map_ns().size() << " namespace IRIs" << '\n'
         ;
      } else {
         BOOST_FOREACH( owlcpp::Triple const& t, store.map_triple() ) {
            std::cout
            << '\"'
            << to_string(t.subj_, store) << "\"\t\""
            << to_string(t.pred_, store) << "\"\t\""
            << to_string(t.obj_, store) << "\"\t\n"
            ;
         }
      }

   } catch(...) {
Пример #27
0
TEST_F(PathTest, root_parent)
{
    const fs::path p("/");

    {
        int i = 0;
        for (auto it = p.begin(); it != p.end(); ++it)
        {
            ++i;
        }

        EXPECT_EQ(1, i);
    }

    const fs::path q(p.parent_path());

    {
        int i = 0;
        for (auto it = q.begin(); it != q.end(); ++it)
        {
            ++i;
        }

        EXPECT_EQ(0, i);
    }
}
Пример #28
0
octree_base<Container, PointT>::octree_base (const boost::filesystem::path& rootname, const bool load_all)
    : root_ ()
    , read_write_mutex_ ()
    , lodPoints_ ()
    , max_depth_ ()
    , treepath_ ()
    , coord_system_ ()
    , resolution_ ()
{
    // Check file extension
    if (boost::filesystem::extension (rootname) != octree_base_node<Container, PointT>::node_index_extension)
    {
        PCL_ERROR ( "[pcl::outofcore::octree_base] Wrong root node file extension: %s. The tree must have a root node ending in %s\n", boost::filesystem::extension (rootname).c_str (), octree_base_node<Container, PointT>::node_index_extension.c_str () );
        PCL_THROW_EXCEPTION (PCLException, "[pcl::outofcore::octree_base] Bad extension. Tree must have a root node ending in .oct_idx\n");
    }

    // Create root_ node
    root_ = new octree_base_node<Container, PointT> (rootname, NULL, load_all);

    // Set root_ nodes tree to the newly created tree
    root_->m_tree_ = this;

    // Set root_ nodes file path
    treepath_ = rootname.parent_path () / (boost::filesystem::basename (rootname) + TREE_EXTENSION_);

    loadFromFile ();
}
Пример #29
0
inline Status listInAbsoluteDirectory(const fs::path& path,
                                      std::vector<std::string>& results,
                                      GlobLimits limits) {
  try {
    if (path.filename() == "*" && !fs::exists(path.parent_path())) {
      return Status(1, "Directory not found: " + path.parent_path().string());
    }

    if (path.filename() == "*" && !fs::is_directory(path.parent_path())) {
      return Status(1, "Path not a directory: " + path.parent_path().string());
    }
  } catch (const fs::filesystem_error& e) {
    return Status(1, e.what());
  }
  genGlobs(path.string(), results, limits);
  return Status(0, "OK");
}
Пример #30
-1
		void parser_filepath(const vrString& filePath, vrString& strParentPath, vrString& strFileName, vrString& strStem, vrString& strExtension)
		{
			const fs::path p1 = filePath;
			strParentPath = p1.parent_path().string();
			strFileName = p1.filename().string();
			strExtension = p1.extension().string();
			strStem = p1.stem().string();
		}