本文整理汇总了C++中boost::filesystem::path::file_string方法的典型用法代码示例。如果您正苦于以下问题:C++ path::file_string方法的具体用法?C++ path::file_string怎么用?C++ path::file_string使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::filesystem::path
的用法示例。
在下文中一共展示了path::file_string方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSize
WidthAndHeight JpgImageInfo::getSize(boost::filesystem::path & aPath)
{
WidthAndHeight result;
FILE *f = fopen(aPath.file_string().data(), "rb");
if (!f)
{
throw std::runtime_error("cannot open file [" + aPath.file_string() + "]");
}
struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr;
cinfo.err = jpeg_std_error(&jerr);
jpeg_create_decompress(&cinfo);
jpeg_stdio_src(&cinfo, f);
ImageInfoException::throwIf(jpeg_read_header(&cinfo, TRUE) == 0, "unable to read jpeg header");
result.width = cinfo.image_width;
result.height = cinfo.image_height;
jpeg_destroy_decompress(&cinfo);
fclose(f);
return result;
}
示例2: loadFile
size_t IOFactory::loadFile( std::list<Chunk> &ret, const boost::filesystem::path &filename, std::string suffix_override, std::string dialect )
{
FileFormatList formatReader;
formatReader = getFileFormatList( filename.file_string(), suffix_override, dialect );
const size_t nimgs_old = ret.size(); // save number of chunks
const std::string with_dialect = dialect.empty() ?
std::string( "" ) : std::string( " with dialect \"" ) + dialect + "\"";
if ( formatReader.empty() ) {
if( !boost::filesystem::exists( filename ) ) {
LOG( Runtime, error ) << util::MSubject( filename )
<< " does not exist as file, and no suitable plugin was found to generate data from "
<< ( suffix_override.empty() ? std::string( "that name" ) : std::string( "the suffix \"" ) + suffix_override + "\"" );
} else if( suffix_override.empty() ) {
LOG( Runtime, error ) << "No plugin found to read " << filename.file_string() << with_dialect;
} else {
LOG( Runtime, error ) << "No plugin supporting the requested suffix " << suffix_override << with_dialect << " was found";
}
} else {
BOOST_FOREACH( FileFormatList::const_reference it, formatReader ) {
LOG( ImageIoDebug, info )
<< "plugin to load file" << with_dialect << " " << util::MSubject( filename ) << ": " << it->getName();
try {
return it->load( ret, filename.file_string(), dialect );
} catch ( std::runtime_error &e ) {
LOG( Runtime, formatReader.size() > 1 ? warning : error )
<< "Failed to load " << filename << " using " << it->getName() << with_dialect << " ( " << e.what() << " )";
}
}
LOG_IF( boost::filesystem::exists( filename ) && formatReader.size() > 1, Runtime, error ) << "No plugin was able to load: " << util::MSubject( filename ) << with_dialect;
}
示例3: remove_all
inline
void remove_all(const boost::filesystem::path& path)
{
if (__is_directory(path)) {
std::vector<boost::filesystem::path> paths;
#if BOOST_FILESYSTEM_VERSION == 2
DIR* dirp = (path.empty() ? ::opendir(".") : ::opendir(path.directory_string().c_str()));
#else
DIR* dirp = (path.empty() ? ::opendir(".") : ::opendir(path.string().c_str()));
#endif
if (dirp) {
struct dirent* dp;
do {
errno = 0;
if ((dp = readdir(dirp)) != 0) {
const std::string path_leaf(dp->d_name);
if (path_leaf != "." && path_leaf != "..")
paths.push_back(path / path_leaf);
}
} while (dp);
::closedir(dirp);
}
std::for_each(paths.begin(), paths.end(), utils::filesystem::remove_all);
}
#if BOOST_FILESYSTEM_VERSION == 2
if (__exists(path))
::remove(path.file_string().c_str());
#else
if (__exists(path))
::remove(path.string().c_str());
#endif
errno = 0;
}
示例4: database_
TEST_F(GeneralTest, DISABLED_memcpy_test)
{
const fs::path filename("/tmp/metadatstoretest");
TCBDB* database_(tcbdbnew());
HANDLE(tcbdbsetcache(database_,
0,
1024));
HANDLE(tcbdbsetcmpfunc(database_,tccmpint64,NULL));
HANDLE(tcbdbopen(database_, filename.file_string().c_str(), BDBOWRITER));
for(int page_size = 10; page_size < 17; ++page_size)
{
const uint64_t size = 1 << page_size;
const uint64_t times = 1 << 10;
std::vector<void*> bufs1;
const uint64_t num_bufs = 1 << 10;
void * b1 = valloc(size);
for(uint64_t i = 0; i < num_bufs; ++i)
{
HANDLE(tcbdbput(database_,&i, sizeof(i),b1, size));
}
youtils::wall_timer wt;
for(uint64_t i = 0; i < times; ++i)
{
for(uint64_t j = 0; j < num_bufs; j++)
{
int _sz = 0;
const void* buf = tcbdbget3(database_, &j, sizeof(j), &_sz);
ASSERT((unsigned)_sz == size);
memcpy(b1, buf, size);
((uint64_t*)b1)[3] = 15;
tcbdbput(database_,&j, sizeof(j), buf, size);
}
}
double time = wt.elapsed();
std::cout << "page_size is " << size << std::endl;
std::cout << "To copy " << size
<< " bytes " << times * num_bufs
<< " times takes "
<< time << " seconds" << std::endl;
std::cout << "this limit voldrv performance to " << (1 << 12) * (times*num_bufs) / ((1 << 21) * time) << "Meg per second" << std::endl ;
// for(uint64_t i = 0; i < num_bufs; ++i)
// {
// free(buf1);
// free(buf2);
// }
}
}
示例5: load_module_path
/*!
* Load all modules in a given path.
* This will recurse into sub-directories.
* Does not throw, prints to std error.
* \param path the filesystem path
*/
static void load_module_path(const fs::path &path){
if (not fs::exists(path)){
//std::cerr << boost::format("Module path \"%s\" not found.") % path.file_string() << std::endl;
return;
}
//try to load the files in this path
if (fs::is_directory(path)){
for(
fs::directory_iterator dir_itr(path);
dir_itr != fs::directory_iterator();
++dir_itr
){
load_module_path(dir_itr->path());
}
return;
}
//its not a directory, try to load it
try{
load_module(path.file_string());
}
catch(const std::exception &err){
std::cerr << boost::format("Error: %s") % err.what() << std::endl;
}
}
示例6: loadDb
Ruleset::Ruleset(boost::filesystem::path filename) {
mDb = NULL;
mBeforeReplacementsPtr = NULL;
mAfterReplacementsPtr = NULL;
mFilename = filename.file_string();
loadDb(filename);
};
示例7:
VirtualDBFVirtualTable::VirtualDBFVirtualTable(
const boost::filesystem::path& path,
const std::string& codePage
): SQLiteVirtualTable(
GetTableName(path),
"VirtualDBF(\"" + replace_all_copy(path.file_string(), "\\", "\\\\") + "\"," + codePage + ")"
)
{}
示例8:
inline std::string native_file_string(boost::filesystem::path const& p)
{
#if BOOST_VERSION >= 104600
return p.string();
#else
return p.file_string();
#endif
}
示例9: offset
BlockData::BlockData(const boost::filesystem::path& block_file_path)
{
block_data_bytes_ = 0;
bytes_ = 0;
int file_descriptor = open(block_file_path.file_string().c_str(), O_RDONLY | O_DIRECT);
if (file_descriptor < 0)
{
LOG4CPLUS_ERROR(Loggers::Service(), "Failed to open file "<<block_file_path<<" to read.");
return;
}
block_data_bytes_ = reinterpret_cast<char*>(BlockDataAllocator::Instance().Allocate());
if (!block_data_bytes_)
{
LOG4CPLUS_ERROR(Loggers::Service(), "Failed to allocate aligned memory buffer.");
close(file_descriptor);
return;
}
//read up to MaxBlockSize bytes to the buffer
size_t offset(0);
int bytes_read(0);
int bytes_left(BlockData::MaxBlockSize);
do
{
bytes_read = pread(file_descriptor, block_data_bytes_ + offset, bytes_left, offset);
if (bytes_read > 0)
{
bytes_left -= bytes_read;
offset += bytes_read;
}
}
while (bytes_left > 0 && bytes_read > 0);
if (bytes_read < 0)
{
LOG4CPLUS_ERROR(Loggers::Service(), "An error occurred while reading file file "<<block_file_path);
close(file_descriptor);
BlockDataAllocator::Instance().Free(block_data_bytes_);
block_data_bytes_ = 0;
return;
}
close(file_descriptor);
bytes_ = offset;
}
示例10: display
void display( const bfs::path & p)
{
long int fc=0,dc=0,ec=0,oc=0;
if( bfs::is_directory(p))
{
cout<<"In Directory:"<< p.directory_string()<<"\n\n";
bfs::directory_iterator i(p), e;
for(i;i!=e;++i)
{
if(bfs::is_directory( i->status()))
{
dc++;
display(*i);
//cout<< i->path().filename()<<"[directory]\n";
}
else if(bfs::is_regular_file(i->status()))
{
fc++;
cout<<i->path().filename()<<"[file]\n";
}
else
{
oc++;
cout<<i->path().filename()<<"[others]\n";
}
}
cout<<"File Count:"<<fc<<"\n";
cout<<"Directory COunt"<<dc<<"\n";
cout<<"Others Count"<<oc<<"\n";
}
else
{
cout<<"File Found"<<p.file_string()<<"\n\n";
}
}
示例11: LoadLibraryA
void *PionPlugin::loadDynamicLibrary(const std::string& plugin_file)
{
#ifdef PION_WIN32
#ifdef _MSC_VER
return LoadLibraryA(plugin_file.c_str());
#else
return LoadLibrary(plugin_file.c_str());
#endif
#else
// convert into a full/absolute/complete path since dlopen()
// does not always search the CWD on some operating systems
const boost::filesystem::path full_path = boost::filesystem::complete(plugin_file);
// NOTE: you must load shared libraries using RTLD_GLOBAL on Unix platforms
// due to a bug in GCC (or Boost::any, depending on which crowd you want to believe).
// see: http://svn.boost.org/trac/boost/ticket/754
return dlopen(full_path.file_string().c_str(), RTLD_LAZY | RTLD_GLOBAL);
#endif
}
示例12: __exists
inline
bool __exists(const boost::filesystem::path& path)
{
if (path.empty()) return false;
struct stat statbuf;
#if BOOST_FILESYSTEM_VERSION == 2
if (::lstat(path.file_string().c_str(), &statbuf) >= 0)
return true;
else {
errno = 0;
return false;
}
#else
if (::lstat(path.string().c_str(), &statbuf) >= 0)
return true;
else {
errno = 0;
return false;
}
#endif
}
示例13: __is_directory
inline
bool __is_directory(const boost::filesystem::path& path)
{
if (path.empty()) return false;
struct stat statbuf;
#if BOOST_FILESYSTEM_VERSION == 2
if (::lstat(path.file_string().c_str(), &statbuf) >= 0)
return ! S_ISLNK(statbuf.st_mode) && S_ISDIR(statbuf.st_mode);
else {
errno = 0;
return false;
}
#else
if (::lstat(path.string().c_str(), &statbuf) >= 0)
return ! S_ISLNK(statbuf.st_mode) && S_ISDIR(statbuf.st_mode);
else {
errno = 0;
return false;
}
#endif
}
示例14:
void OMW::Engine::addResourcesDirectory (const boost::filesystem::path& path)
{
mOgre.getRoot()->addResourceLocation (path.file_string(), "FileSystem",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true);
}