本文整理汇总了C++中boost::filesystem::path::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ path::c_str方法的具体用法?C++ path::c_str怎么用?C++ path::c_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::filesystem::path
的用法示例。
在下文中一共展示了path::c_str方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sql
bool
filesystem::mount( const boost::filesystem::path& filepath )
{
db_.reset( new sqlite() );
if ( db_->open( filepath.c_str() ) ) {
filename_ = filepath.string();
if ( internal::fs::mount( *db_, format_version_ ) ) {
db_->set_fs_format_version( format_version_ );
if ( format_version_ >= 3 ) {
adfs::stmt sql( *db_ );
sql.exec( "PRAGMA FOREIGN_KEYS = ON" );
}
return true;
}
}
db_.reset();
return false;
}
示例2: Scan
void Scan(const boost::filesystem::path & path) {
if(args.verbose)
printf("scanning %s\n", path.c_str());
if(!boost::filesystem::exists(path))
throw OpenDirException();
if(!boost::filesystem::is_directory(path))
throw OpenDirException();
// dont parse SVN
if(path.has_extension() && (strcasecmp(path.extension().c_str(), ".svn")==0))
return;
boost::filesystem::directory_iterator end;
for( boost::filesystem::directory_iterator itor = boost::filesystem::directory_iterator( path ); itor != end; itor++)
if(boost::filesystem::is_regular_file( itor->status() ))
if( !itor->path().has_extension() || ((strcasecmp(itor->path().extension().c_str(), ".h")==0) || (strcasecmp(itor->path().extension().c_str(), ".hpp")==0)) )
Add( itor->path().string() );
if( boost::filesystem::is_symlink(path) )
return; // FIXME: better way to deal with gphoto's recursive symlinks?
for( boost::filesystem::directory_iterator itor = boost::filesystem::directory_iterator( path ); itor != end; itor++)
if(boost::filesystem::is_directory( itor->status() ))
Scan( itor->path() );
}
示例3: open
void RandomAccessFile::open(const boost::filesystem::path& path, RandomAccessFile::Mode mode, uint64_t size)
{
int m;
switch (mode) {
case READ: m = O_RDONLY; break;
case WRITE: m = O_WRONLY|O_CREAT; break;
case READWRITE: m = O_RDWR|O_CREAT; break;
default: throw std::ios_base::failure("Unknown open-mode");
}
_size = fs::exists(path) ? fs::file_size(path) : 0;
if (_size != size) {
if (size == 0) {
size = _size;
} else if (_size != 0) {
ostringstream buf;
buf << path << " exists with mismatching size, (" << size << " : " << fs::file_size(path) << ")";
throw bsys::system_error(bsys::errc::make_error_code(bsys::errc::file_exists), buf.str());
}
}
_fd = ::open(path.c_str(), m, S_IRUSR|S_IWUSR);
if (_fd < 0) {
throw bsys::system_error(bsys::errc::make_error_code(static_cast<bsys::errc::errc_t>(errno)), "Failed opening "+path.string());
} else if ((_size == 0) && (ftruncate(_fd, size) == -1)) {
::close(_fd);
ostringstream buf;
buf << "Failed truncating " << path.string() << " to " << size;
throw bsys::system_error(bsys::errc::make_error_code(static_cast<bsys::errc::errc_t>(errno)), buf.str());
}
_path = path;
_size = size;
}
示例4: DownloadFile
int DownloadFile(std::string url, boost::filesystem::path target_file_path)
{
int err = 0;
printf("bootstrap: Downloading blockchain from %s. \n", url.c_str());
CURL *curlHandle = curl_easy_init();
curl_easy_setopt(curlHandle, CURLOPT_URL, url.c_str());
curl_easy_setopt(curlHandle, CURLOPT_NOPROGRESS, 1L);
curl_easy_setopt(curlHandle, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curlHandle, CURLOPT_FOLLOWLOCATION, 1L);
FILE *file = fopen(target_file_path.c_str(), "wb");
if(file)
{
curl_easy_setopt(curlHandle, CURLOPT_WRITEDATA, file);
CURLcode curl_err = curl_easy_perform(curlHandle);
if (curl_err != CURLE_OK)
printf("bootstrap: Error downloading from %s. Error: %s.\n", url.c_str(), curl_easy_strerror(curl_err));
fclose(file);
err = (int)curl_err;
}
else
{
printf("bootstrap: Download error: Unable to open output file for writing: %s.\n", target_file_path.c_str());
err = -1;
}
curl_easy_cleanup(curlHandle);
return err;
}
示例5: return
bool
touch(const bfs::path& path)
{
if (pathExists(path)) {
return (utimes(path.c_str(), NULL) == 0);
}
if (!isDirectory(path.parent_path())) {
return false;
}
int fd = open(path.c_str(), O_EXCL | O_CREAT | O_WRONLY, 0644);
if (fd < 0) return false;
close(fd);
return true;
}
示例6: partition_parse
int partition_parse(int **declarations,
boost::filesystem::path input_filename,
boost::filesystem::path functions_filename,
boost::filesystem::path config_filename,
int not_sc_flag)
{
FILE *IN = safe_fopen_read(input_filename);
int retval = partitionParse(declarations, IN,
const_cast<char *> (functions_filename.c_str()),
const_cast<char *> (config_filename.c_str()),
not_sc_flag); // the 0 means not self conjugate.
fclose(IN);
return retval;
}
示例7: readOptions
KillerImpl::Options readOptions(const boost::filesystem::path &path)
{
boost::property_tree::ptree ptree;
boost::property_tree::read_json(path.c_str(), ptree);
KillerImpl::Options options;
bunsan::config::input_archive<boost::property_tree::ptree>::load_from_ptree(options, ptree);
return options;
}
示例8: runtime_error
std::shared_ptr<rett> createAny(const boost::filesystem::path & libpath, const std::string & methodName)
{
#ifdef VCMI_ANDROID
// android currently doesn't support loading libs dynamically, so the access to the known libraries
// is possible only via specializations of this template
throw std::runtime_error("Could not resolve ai library " + libpath.generic_string());
#else
typedef void(* TGetAIFun)(std::shared_ptr<rett> &);
typedef void(* TGetNameFun)(char *);
char temp[150];
TGetAIFun getAI = nullptr;
TGetNameFun getName = nullptr;
#ifdef VCMI_WINDOWS
HMODULE dll = LoadLibraryW(libpath.c_str());
if (dll)
{
getName = (TGetNameFun)GetProcAddress(dll, "GetAiName");
getAI = (TGetAIFun)GetProcAddress(dll, methodName.c_str());
}
#else // !VCMI_WINDOWS
void *dll = dlopen(libpath.string().c_str(), RTLD_LOCAL | RTLD_LAZY);
if (dll)
{
getName = (TGetNameFun)dlsym(dll, "GetAiName");
getAI = (TGetAIFun)dlsym(dll, methodName.c_str());
}
#endif // VCMI_WINDOWS
if (!dll)
{
logGlobal->error("Cannot open dynamic library (%s). Throwing...", libpath.string());
throw std::runtime_error("Cannot open dynamic library");
}
else if(!getName || !getAI)
{
logGlobal->error("%s does not export method %s", libpath.string(), methodName);
#ifdef VCMI_WINDOWS
FreeLibrary(dll);
#else
dlclose(dll);
#endif
throw std::runtime_error("Cannot find method " + methodName);
}
getName(temp);
logGlobal->info("Loaded %s", temp);
std::shared_ptr<rett> ret;
getAI(ret);
if(!ret)
logGlobal->error("Cannot get AI!");
return ret;
#endif //!VCMI_ANDROID
}
示例9:
void
FsWatcher::deleteFile(const fs::path& filename)
{
sqlite3_stmt* stmt;
sqlite3_prepare_v2(m_db, "DELETE FROM Files WHERE filename = ?;", -1, &stmt, 0);
sqlite3_bind_text(stmt, 1, filename.c_str(), -1, SQLITE_STATIC);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
}
示例10: f
template<typename ContainerT, typename PointT> void
OutofcoreOctreeBase<ContainerT, PointT>::writeVPythonVisual (const boost::filesystem::path filename)
{
std::ofstream f (filename.c_str ());
f << "from visual import *\n\n";
root_->writeVPythonVisual (f);
}
示例11: setLogFile
void LogSink::setLogFile (boost::filesystem::path const& path)
{
bool const wasOpened = m_logFile.open (path.c_str ());
if (! wasOpened)
{
Log (lsFATAL) << "Unable to open logfile " << path;
}
}
示例12: Files
void
FsWatcher::addFile(const fs::path& filename)
{
sqlite3_stmt* stmt;
sqlite3_prepare_v2(m_db, "INSERT OR IGNORE INTO Files(filename) VALUES(?);", -1, &stmt, 0);
sqlite3_bind_text(stmt, 1, filename.c_str(), -1, SQLITE_STATIC);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
}
示例13: PugiXMLParseResultPrettifier
void PugiXMLParseResultPrettifier ( const pugi::xml_parse_result& aLoadResult , const boost::filesystem::path& aPath , const std::vector<uint8_t>& aFile )
{
log ( Error() , "Failed to parse file " , aPath.c_str() , ". PugiXML returned the following description " , Quote ( aLoadResult.description() ) , "." );
std::size_t lLineCounter ( 1 );
std::vector<uint8_t>::const_iterator lIt0 ( aFile.begin() );
std::vector<uint8_t>::const_iterator lIt1 ( aFile.begin() + aLoadResult.offset );
std::vector<uint8_t>::const_iterator lIt2 ( lIt1 );
for ( ; lIt0!=lIt1 ; ++lIt0 )
{
if ( *lIt0 == '\n' )
{
lLineCounter++;
}
}
for ( ; lIt1 != aFile.begin() ; --lIt1 )
{
if ( *lIt1 == '\n' )
{
++lIt1;
break;
}
}
for ( ; lIt2 != aFile.end() ; ++lIt2 )
{
if ( *lIt2 == '\n' )
{
--lIt2;
break;
}
}
std::size_t lDist0 ( lIt0 - lIt1 );
std::size_t lDist1 ( lIt2 - lIt0 );
std::string lLine;
lLine.reserve ( lIt2 - lIt1 );
for ( ; lIt1 != lIt2 ; ++lIt1 )
{
if ( isprint ( *lIt1 ) || *lIt1==10 )
{
lLine += *lIt1;
}
else
{
lLine += '#';
}
}
log ( Error() , "Error occured at line number " , Integer ( lLineCounter ) ,
", character " , Integer ( lDist0+1 ) , "\n"
"LINE : " , lLine , "\n"
"ERROR LOCATION : " , std::string ( lDist0 , '_' ) , "^" , std::string ( lDist1 , '_' ) );
}
示例14: strerror
BitsetSaver::BitsetSaver(const boost::filesystem::path filePath) :
filePath_(filePath),
os_(filePath.c_str())
{
if (!os_)
{
const boost::format message = boost::format("Failed to open file %s for writing: %s") % filePath_ % strerror(errno);
BOOST_THROW_EXCEPTION(common::IoException(errno, message.str()));
}
}
示例15: EXPECT_STORED_FILE_DATA_CORRECT
static void EXPECT_STORED_FILE_DATA_CORRECT(const Data &data, const bf::path &filepath) {
EXPECT_EQ(data.size(), bf::file_size(filepath));
ifstream file(filepath.c_str(), std::ios::binary);
char *read_data = new char[data.size()];
file.read(read_data, data.size());
EXPECT_EQ(0, std::memcmp(data.data(), read_data, data.size()));
delete[] read_data;
}