本文整理汇总了C++中boost::filesystem::path::filename方法的典型用法代码示例。如果您正苦于以下问题:C++ path::filename方法的具体用法?C++ path::filename怎么用?C++ path::filename使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::filesystem::path
的用法示例。
在下文中一共展示了path::filename方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TMPgetLibraryName
/**
* @brief Get the plug-in name of the filename provided.
*
* @code
* // return "toto".
* utils::Module::getPluginName("/home/foo/bar/libtoto.so");
* @endcode
*
* @param path The path of the file to convert;
* @return The plug-in name;
*
* TODO function from ModuleManager
*/
static std::string TMPgetLibraryName(const boost::filesystem::path& file)
{
namespace fs = boost::filesystem;
std::string library;
#if BOOST_VERSION > 104500
if (file.filename().string().compare(0, 3, "lib") == 0) {
library.append(file.filename().string(), 3, std::string::npos);
}
#else
if (file.filename().compare(0, 3, "lib") == 0) {
library.append(file.filename(), 3, std::string::npos);
}
#endif
#ifdef BOOST_WINDOWS
if (fs::extension(file) == ".dll") {
library.assign(library, 0, library.size() - 4);
}
#else
if (fs::extension(file) == ".so") {
library.assign(library, 0, library.size() - 3);
}
#endif
return library;
}
示例2: rename
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));
}
}
示例3: leaf
inline std::string leaf(boost::filesystem::path const& p)
{
#if BOOST_VERSION >= 104600 && BOOST_FILESYSTEM_VERSION >= 3
return p.filename().string();
#else
return p.filename();
#endif
}
示例4: ToString
static std::string ToString(const boost::filesystem::path& p)
{
#if BOOST_HAS_FILESYSTEM_V3 == 1
return p.filename().string();
#else
return p.filename();
#endif
}
示例5: 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;
}
示例6: removeAsset
uint64_t AssetStore::removeAsset(const boost::filesystem::path& assetPath) noexcept
{
BOOST_LOG_SEV(bithorded::storeLog, info) << "removing asset " << assetPath.filename();
auto tigerId = _index.removeAsset(assetPath.filename().native());
if (!tigerId.empty()) {
unlink(_tigerFolder / tigerId);
}
return remove_file_recursive(assetPath);
}
示例7: make_pair
//-------------------------------------------------------
const EntityIdAndHandlerId
Filename2EntityIdAndHandlerId(const boost::filesystem::path & filename)
{
if (!filename.has_filename())
{
throw Safir::Dob::Typesystem::IllegalValueException
(L"Filename2EntityAndHandler: Could not decompose filename : " +
Safir::Dob::Typesystem::Utilities::ToWstring(filename.string()),__WFILE__,__LINE__);
}
#if defined (BOOST_FILESYSTEM_VERSION) && BOOST_FILESYSTEM_VERSION == 3
const std::string leaf = filename.filename().string();
#else
const std::string leaf = filename.filename();
#endif
size_t separatorIndex = leaf.find('@');
if (separatorIndex == std::string::npos)
{
throw Safir::Dob::Typesystem::IllegalValueException
(L"Filename2EntityAndHandler: Could not decompose filename : " +
Safir::Dob::Typesystem::Utilities::ToWstring(filename.string()),__WFILE__,__LINE__);
}
const std::string typeName = leaf.substr(0,separatorIndex);
size_t secondSeparatorIndex = leaf.find('@',separatorIndex+1);
if (secondSeparatorIndex == std::string::npos)
{
throw Safir::Dob::Typesystem::IllegalValueException
(L"Filename2EntityAndHandler: Could not decompose filename : " +
Safir::Dob::Typesystem::Utilities::ToWstring(filename.string()),__WFILE__,__LINE__);
}
const std::string instance = leaf.substr(separatorIndex + 1,secondSeparatorIndex - separatorIndex - 1);
size_t extIndex = leaf.find('.',secondSeparatorIndex);
if (extIndex == std::string::npos)
{
throw Safir::Dob::Typesystem::IllegalValueException
(L"Filename2EntityAndHandler: Could not decompose filename : " +
Safir::Dob::Typesystem::Utilities::ToWstring(filename.string()),__WFILE__,__LINE__);
}
const std::string handler = leaf.substr(secondSeparatorIndex + 1,extIndex - secondSeparatorIndex - 1);
return std::make_pair(Safir::Dob::Typesystem::EntityId
(Safir::Dob::Typesystem::Operations::GetTypeId(Safir::Dob::Typesystem::Utilities::ToWstring(typeName)),
Safir::Dob::Typesystem::InstanceId( boost::lexical_cast<Safir::Dob::Typesystem::Int64>(instance))),
Safir::Dob::Typesystem::HandlerId(boost::lexical_cast<Safir::Dob::Typesystem::Int64>(handler)));
}
示例8: listInAbsoluteDirectory
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: processFile
ProcessResults processFile(fs::path file, Params& params)
{
ProcessResults result;
Pex::Binary pex;
try
{
Pex::FileReader reader(file.string());
reader.read(pex);
}
catch(std::exception& ex)
{
result.push_back(boost::str(boost::format("ERROR: %1% : %2%") % file.string() % ex.what()));
return result;
}
if (params.outputAssembly)
{
fs::path asmFile = params.assemblyDir / file.filename().replace_extension(".pas");
try
{
std::ofstream asmStream(asmFile.string());
Decompiler::AsmCoder asmCoder(new Decompiler::StreamWriter(asmStream));
asmCoder.code(pex);
result.push_back(boost::str(boost::format("%1% dissassembled to %2%") % file.string() % asmFile.string()));
}
catch(std::exception& ex)
{
result.push_back(boost::str(boost::format("ERROR: %1% : %2%") % file.string() % ex.what()));
fs::remove(asmFile);
}
}
fs::path pscFile = params.papyrusDir / file.filename().replace_extension(".psc");
try
{
std::ofstream pscStream(pscFile.string());
Decompiler::PscCoder pscCoder(new Decompiler::StreamWriter(pscStream));
pscCoder.outputAsmComment(params.outputComment).code(pex);
result.push_back(boost::str(boost::format("%1% decompiled to %2%") % file.string() % pscFile.string()));
}
catch(std::exception& ex)
{
result.push_back(boost::str(boost::format("ERROR: %1% : %2%") % file.string() % ex.what()));
fs::remove(pscFile);
}
return result;
}
示例10: updated
// FSWatcher::Watcher::updated
virtual void updated(const boost::filesystem::path& filePath) {
string fstr = filePath.filename().string();
if (!boost::algorithm::ends_with(fstr, ".json") ||
boost::algorithm::starts_with(fstr, "."))
return;
readConfig(filePath.string());
}
示例11: ParseException
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;
}
示例12: 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");
}
示例13: write_pic
void write_pic(const fs::path& path, const char* buff, const int length)
{
auto curname = path.filename().replace_extension();
auto rawname = path;
rawname.append(curname.c_str());
auto pngname = rawname;
pngname += ".png";
auto mskname = rawname;
mskname += ".msk";
auto lyrname = rawname;
lyrname += ".lyr";
YKGHDR* ghdr = (YKGHDR*)buff;
if (ghdr->rgb_length)
{
write_file(pngname, buff + ghdr->rgb_offset, ghdr->rgb_length);
}
if (ghdr->msk_length)
{
write_file(mskname, buff + ghdr->msk_offset, ghdr->msk_length);
}
if (ghdr->__lyr_len)
{
write_file(lyrname, buff + ghdr->__lyr_off, ghdr->__lyr_len);
}
(void)length; // not using this variable.
return;
}
示例14: move_file
void move_file(const char *t_path,fs::path p ) {
try {
fs::rename(p, fs::path(t_path)/p.filename());
} catch(fs::filesystem_error &e) {
std::cerr << e.what() << std::endl;
}
}
示例15: writeAttachment
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();
}