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


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

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


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

示例1:

/*
 * \brief Non-recursive GLOB operation
 */
std::vector<boost::filesystem::path> Glob::glob( const boost::filesystem::path& dir ) const
{
    std::vector<boost::filesystem::path> files;
    if (boost::filesystem::is_directory(dir))
    {
        for( boost::filesystem::directory_iterator it(dir), end;
             it != end;
             ++it)
        {
            boost::smatch match;
            if (boost::regex_match( it->path().leaf().string(), match, pattern_ ))
            {
                EAGLE_DEBUG(4, "... " << it->path().leaf() );
                files.push_back( it->path() );
            }
        }
    } else {
        boost::smatch match;
        if (boost::regex_match( dir.leaf().string(), match, pattern_ ))
        {
            EAGLE_DEBUG(4, "... " << dir.leaf() );
            // ... return vector with only one element
            files.push_back( dir );
        }
    }
    if (files.empty())
    {
        EAGLE_WARNING( (boost::format("Regex \"%s\" did not match any files in %s") % pattern_ % dir ).str() );
    } else {
        std::stable_sort(files.begin(),files.end());
    }
    return files;
}
开发者ID:sequencing,项目名称:EAGLE,代码行数:36,代码来源:FileSystem.cpp

示例2: leaf

    inline std::string leaf(boost::filesystem::path const& p)
    {
#if BOOST_FILESYSTEM_VERSION >= 3
        return p.leaf().string();
#else
        return p.leaf();
#endif
    }
开发者ID:41i,项目名称:hpx,代码行数:8,代码来源:filesystem_compatibility.hpp

示例3: copy_files

    inline
    void copy_files(const boost::filesystem::path& path_from,
		    const boost::filesystem::path& path_to)
    {
      if (path_from.empty() || path_to.empty())
	throw std::runtime_error("empty path");
      
      if (! boost::filesystem::exists(path_from) || ! boost::filesystem::exists(path_to))
	throw std::runtime_error("no path");
      
      if (! boost::filesystem::is_directory(path_to))
	throw std::runtime_error("destination is not a directory");
      
      boost::filesystem::path destination = path_to / path_from.leaf();
      
      if (! boost::filesystem::is_directory(path_from))
	boost::filesystem::copy_file(path_from, destination);
      else {
	boost::filesystem::create_directory(destination);
	
	boost::filesystem::directory_iterator iter_end;
	for (boost::filesystem::directory_iterator iter(path_from); iter != iter_end; ++ iter)
	  copy_files(*iter, destination);
      }
    }
开发者ID:hitochan777,项目名称:cicada,代码行数:25,代码来源:filesystem.hpp

示例4: MakePackedImage

void MakePackedImage(
    boost::filesystem::path const& ImagePath,
    boost::filesystem::path const& ScriptPath,
    std::string const& DictionaryName,
    std::vector<std::string> const& SourceList)
{
    
    std::vector<ImageEntryType> ImageList;
    
    boost::filesystem::ofstream DictionaryFile(ScriptPath, std::ios::trunc);
    
    for (auto i=begin(SourceList); i!=end(SourceList); ++i)
    {
        ScanFile(ImageList, *i);
    }

    // Construct the module name from the filename
    std::string ModuleName;
    {
        auto p=ScriptPath.leaf();
        p.replace_extension();
        ModuleName=p.string();
    }

    // Sort according to size (max edge length)
    std::sort(ImageList.begin(), ImageList.end(), [](ImageEntryType const& Lhs, ImageEntryType const& Rhs) ->bool {
        auto&& a=*Lhs.Image;
        auto&& b=*Rhs.Image;
        return std::max(a.get_width(), a.get_height()) > std::max(b.get_width(), b.get_height());
    });
    
    PackImages(ImagePath, ImageList);
    WriteDictionary(DictionaryFile, ModuleName, DictionaryName, "NinePatches", ImageList);
}
开发者ID:LiMuBei,项目名称:image-packer,代码行数:34,代码来源:ImagePacker.cpp

示例5: ScanFile

void ScanFile(std::vector<ImageEntryType>& List, boost::filesystem::path const& Path)
{
    if (!is_directory(Path))
    {
        AddFile(List, Path, Path.leaf());
        return;
    }
    
    using namespace boost::filesystem;
    typedef boost::filesystem::recursive_directory_iterator Iterator;
    std::size_t BaseOffset=std::distance(Path.begin(), Path.end());
    for (Iterator i(Path), ie; i!=ie; ++i)
    {
        if (is_symlink(*i))
            i.no_push();
        
        if (!is_regular_file(*i))
            continue;
        
        path Absolute=*i;
        path Relative;
        auto j=Absolute.begin();
        
        std::size_t c=0;
        for (; j!=Absolute.end(); ++j, ++c)
            if (c >= BaseOffset)
                Relative /= *j;
        
        if (!Relative.empty())
            AddFile(List, Path/Relative, Relative);
    }
}
开发者ID:LiMuBei,项目名称:image-packer,代码行数:32,代码来源:ImagePacker.cpp

示例6:

     BOOST_FOREACH(const boost::filesystem::path& fname,filesFound)
     {
         boost::smatch what;
-        std::string leaf = fname.leaf();
+        std::string leaf = fname.filename().string();
 
         if (!boost::regex_match(leaf, what, re)) 
             continue;
开发者ID:Sphonic,项目名称:pkgsrc-joyent,代码行数:8,代码来源:patch-cgatools_mapping_LaneBatchCache.cpp

示例7: while

//! get the relative file path from the host directory
static std::string get_rel_file_path(const fs::path &file){
    fs::path abs_path = file.branch_path();
    fs::path rel_path = file.leaf();
    while (not abs_path.empty() and abs_path.leaf() != "host"){
        rel_path = abs_path.leaf() / rel_path;
        abs_path = abs_path.branch_path();
    }
    return rel_path.string();
}
开发者ID:GREO,项目名称:uhd,代码行数:10,代码来源:log.cpp

示例8: OnImportOverwrite

CSaveImporterBase::OVERWRITE_PROMPT_RETURN MemoryCardManagerDialog::OnImportOverwrite(const boost::filesystem::path& filePath)
{
    std::string fileName = filePath.leaf().string();
    QString msg("File %1 already exists.\n\nOverwrite?");
    QMessageBox::StandardButton resBtn = QMessageBox::question(this, "Overwrite?",
                                                               msg.arg(fileName.c_str()),
                                                               QMessageBox::Yes | QMessageBox::No,
                                                               QMessageBox::Yes);
    return (resBtn == QMessageBox::Yes) ? CSaveImporterBase::OVERWRITE_YES : CSaveImporterBase::OVERWRITE_NO;
}
开发者ID:Phatcat,项目名称:Play-,代码行数:10,代码来源:memorycardmanagerdialog.cpp

示例9: AddFile

void AddFile(std::vector<ImageEntryType>& List, boost::filesystem::path const& FilePath, boost::filesystem::path const& RelativeFilePath)
{
    // Check if this is a supported image format
    if (extension(FilePath)!=".png")
        return;

    std::cout << "Loading " << FilePath.string() << std::endl;
        
    auto Image=replay::pixbuf_io::load_from_file(FilePath);
    ImageEntryType Entry;
    Entry.RelativePath=RelativeFilePath;

    // Check if this is a 9-patch
    if (boost::algorithm::ends_with(FilePath.leaf().string(), ".9.png"))
    {
        auto w=Image->get_width(), h=Image->get_height();
        if (Image->get_channels() != 4)
            throw std::invalid_argument("9-patch must have alpha channel");

        if (w < 4 || h < 4)
            throw std::invalid_argument("9-patch images must be at least 4x4");

        // Analyze top and left
        auto ScalableX=AnalyzeLine(*Image, h-1, 0);
        auto ScalableY=AnalyzeLine(*Image, 0, 1);
        
        // Analyze bottom and right
        auto FillX=AnalyzeLine(*Image, 0, 0);
        auto FillY=AnalyzeLine(*Image, w-1, 1);

        if (std::get<0>(FillX)==std::get<1>(FillX))
            FillX=ScalableX;

        if (std::get<0>(FillY)==std::get<1>(FillY))
            FillY=ScalableY;
        
        Entry.ScaleableArea.set(std::get<0>(ScalableX), std::get<0>(ScalableY),
								std::get<1>(ScalableX), std::get<1>(ScalableY));

        Entry.FillArea.set(std::get<0>(FillX), std::get<0>(FillY),
						   std::get<1>(FillX), std::get<1>(FillY));

        // Extract the actual image data
        Entry.Image=Image->get_sub_image(1, 1, w-2, h-2);

        Entry.IsNinePatch=true;
    }
    else
    {
        Entry.Image=Image;
    }
        
        
    List.push_back(Entry);
}
开发者ID:LiMuBei,项目名称:image-packer,代码行数:55,代码来源:ImagePacker.cpp

示例10: get_arena_xml_content

static xmlDocPtr get_arena_xml_content(const boost::filesystem::path &path) {
    std::ifstream is(path.string());
    std::string content((std::istreambuf_iterator<char>(is)), std::istreambuf_iterator<char>());
    std::string base_file_name = path.leaf().string();
    size_t pos;
    while ((pos = content.find(base_file_name)) != -1) {
        content.replace(pos, base_file_name.length(), "arena");
    }
    xmlDocPtr doc = xmlReadMemory(content.c_str(), (int) content.length(), base_file_name.c_str(), NULL, 0);
    return doc;
}
开发者ID:AziCorporation,项目名称:wotreplay-parser,代码行数:11,代码来源:arena.cpp

示例11: leaf

    inline SAGA_EXPORT std::string leaf(boost::filesystem::path const& p)
    {
#if BOOST_FILESYSTEM_VERSION == 3
        return p.filename().string();
#else
#if BOOST_VERSION >= 103600
        return p.empty() ? std::string() : *--p.end();
#else
        return p.leaf();
#endif
#endif
    }
开发者ID:saga-project,项目名称:saga-cpp,代码行数:12,代码来源:path_leaf.hpp

示例12: load_images

		/*
		 *  Load images for a given directory.
		 *  @param dir The directory of the image set.
		 */
		void load_images( const std::string& dir )
		{
			filesystem::path directory(dir);

			if (not filesystem::is_directory(directory)) {
				std::cerr << "Error: failed to locate image directory.\n";
				return;
			}

			int num = 0;
			for (auto it = filesystem::directory_iterator(directory);
					it != filesystem::directory_iterator(); ++it, ++num) {
				const filesystem::path imagepath = it->path();
				cv::Mat image = cv::imread(imagepath.string(), cv::IMREAD_GRAYSCALE);
				if (image.empty())
					std::cerr << "\tWarning: failed to load image " << imagepath.string() << "\n";
				else
					retriever.addImage(image, imagepath.leaf().string());
			}
		}
开发者ID:PierreHao,项目名称:Cires,代码行数:24,代码来源:main.cpp

示例13: set_old

fs::path JobDir::set_old(fs::path const& file)
{
  fs::path new_path;
  fs::path old_path;
  try {
    new_path = m_impl->new_dir / file.leaf();
    old_path = m_impl->old_dir / file.leaf();
  } catch (boost::filesystem::filesystem_error const& e) {
    throw JobDirError(e.what());
  }
  bool e = std::rename(new_path.string().c_str(), old_path.string().c_str());
  if (e) {
    std::string msg("rename failed for ");
    msg += new_path.string();
    msg += " (" + boost::lexical_cast<std::string>(errno) + ')';
    throw JobDirError(msg);
  }

  return old_path;
}
开发者ID:ic-hep,项目名称:emi3,代码行数:20,代码来源:jobdir.cpp

示例14: run_scripts

void run_scripts(const boost::filesystem::path &p, PyObject *m)
{
	std::regex filePattern("^.+\\.py$");

	if (!boost::filesystem::is_directory(p))
	{
		if (std::regex_match(p.leaf().string(), filePattern))
		{
			std::ifstream input(p.string().c_str());

			if (input.is_open())
			{
				std::string str((std::istreambuf_iterator<char>(input)), std::istreambuf_iterator<char>());

				PyRun_String(str.c_str(), Py_file_input, m, m);
				input.close();
			}
		}
	}
}
开发者ID:Rollmops,项目名称:PyPrepar3D,代码行数:20,代码来源:script_loader.cpp

示例15: handleFileRenamed

	void TorrentFilesModel::handleFileRenamed (int torrent, int file, const QString& newName)
	{
		if (torrent != Index_)
			return;

		const auto filePos = std::find_if (Path2Node_.begin (), Path2Node_.end (),
				[file] (const Path2Node_t::value_type& pair)
					{ return pair.second->FileIndex_ == file; });
		if (filePos == Path2Node_.end ())
		{
			qWarning () << Q_FUNC_INFO
					<< "unknown file index"
					<< file
					<< "for torrent"
					<< torrent
					<< "was renamed to"
					<< newName;
			return;
		}

		const auto node = filePos->second;
		ClearEmptyParents (filePos->first);

		const boost::filesystem::path newPath { newName.toUtf8 ().constData () };

		const auto& parentNode = MkParentIfDoesntExist (newPath, true);

		node->Name_ = QString::fromUtf8 (newPath.leaf ().string ().c_str ());
		node->Reparent (parentNode);

		beginInsertRows (FindIndex (newPath.branch_path ()), parentNode->GetRowCount (), parentNode->GetRowCount ());
		Path2Node_ [newPath] = node;
		parentNode->AppendExisting (node);
		endInsertRows ();

		UpdateSizeGraph (RootNode_);
	}
开发者ID:,项目名称:,代码行数:37,代码来源:


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