本文整理汇总了C++中Path_t::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ Path_t::c_str方法的具体用法?C++ Path_t::c_str怎么用?C++ Path_t::c_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path_t
的用法示例。
在下文中一共展示了Path_t::c_str方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rename
int FuseContext::rename (const char *oldpath, const char *newpath)
{
namespace fs = boost::filesystem;
Path_t oldwrap = m_realRoot / oldpath;
Path_t newwrap = m_realRoot / newpath;
// if the move overwrites a file then copy data, increment version, and
// unlink the old file
if( fs::exists( newwrap ) )
{
// perform the move
int result = ::rename( oldwrap.c_str(), newwrap.c_str() );
if( result < 0 )
return -errno;
m_backend->db().incrementVersion( Path_t(newpath) );
m_backend->db().unlink( Path_t(oldpath) );
return result;
}
else
{
int result = ::rename( oldwrap.c_str(), newwrap.c_str() );
if( result < 0 )
return -errno;
m_backend->db().mknod( Path_t(newpath) );
m_backend->db().unlink( Path_t(oldpath) );
return result;
}
}
示例2: link
int FuseContext::link (const char *oldpath, const char *newpath)
{
Path_t oldwrap = m_realRoot / oldpath;
Path_t newwrap = m_realRoot / newpath;
int result = ::link( oldwrap.c_str(), newwrap.c_str() );
if( result < 0 )
return -errno;
return result;
}
示例3: getattr
int FuseContext::getattr (const char *path, struct stat *out)
{
namespace fs = boost::filesystem;
Path_t wrapped = m_realRoot / path;
int result = ::lstat( wrapped.c_str(), out );
// if we failed to stat the underlying file, then check to see if the
// file is unsubscribed
if( result < 0 )
{
if( m_backend->db().isSubscribed( m_relDir / path ) )
return -errno;
else
{
out->st_mode = S_IFREG | S_IRUSR | S_IWUSR;
out->st_nlink = 0;
out->st_uid = getuid();
out->st_gid = getgid();
out->st_size = 0;
out->st_atime = 0;
out->st_mtime = 0;
out->st_ctime = 0;
return 0;
}
}
return result;
}
示例4: mkdir
int FuseContext::mkdir (const char *path, mode_t mode)
{
namespace fs = boost::filesystem;
Path_t wrapped = m_realRoot / path;
// first we make sure that the parent directory exists
Path_t parent = wrapped.parent_path();
Path_t filename = wrapped.filename();
if( !fs::exists(parent) )
return -ENOENT;
try
{
m_backend->db().mknod( Path_t(path) );
}
catch( const std::exception& ex )
{
std::cerr << "FuseContext::mkdir: "
<< "\n path: " << path
<< "\n real: " << wrapped
<< "\n err: " << ex.what()
<< "\n";
return -EINVAL;
}
// create the directory
int result = ::mkdir( wrapped.c_str(), mode );
if( result )
return -errno;
return 0;
}
示例5: getxattr
int FuseContext::getxattr (const char *path,
const char *key,
char *value,
size_t bufsize)
{
std::string attr(key);
if( attr == "obfs:checkout" )
{
std::stringstream report;
report << "FuseContext::getxattr : intercepted checkout hook for"
<< path <<"\n";
std::cout << report.str();
m_backend->checkout( m_relDir / path );
return 0;
}
else if( attr == "obfs:release" )
{
std::stringstream report;
report << "FuseContext::getxattr : intercepted release hook for"
<< path <<"\n";
std::cout << report.str();
m_backend->release( m_relDir / path );
return 0;
}
else
{
Path_t wrapped = m_realRoot / path;
int result = ::getxattr( wrapped.c_str(), key, value, bufsize );
if( result < 0 )
return -errno;
return result;
}
}
示例6: statfs
int FuseContext::statfs (const char *path, struct statvfs *buf)
{
Path_t wrapped = m_realRoot / path;
int result = ::statvfs( wrapped.c_str(), buf );
if( result < 0 )
return -errno;
return result;
}
示例7: listxattr
int FuseContext::listxattr (const char *path, char *buf, size_t bufsize)
{
Path_t wrapped = m_realRoot / path;
int result = ::listxattr( wrapped.c_str(), buf, bufsize );
if( result < 0 )
return -errno;
return result;
}
示例8: removexattr
int FuseContext::removexattr (const char *path, const char *key)
{
Path_t wrapped = m_realRoot / path;
int result = ::removexattr( wrapped.c_str(), key );
if( result < 0 )
return -errno;
return result;
}
示例9: access
int FuseContext::access (const char *path, int mode)
{
Path_t wrapped = m_realRoot / path;
int result = ::access( wrapped.c_str(), mode );
if( result < 0 )
return -errno;
return result;
}
示例10: chown
int FuseContext::chown (const char *path, uid_t owner, gid_t group)
{
namespace fs = boost::filesystem;
Path_t wrapped = (m_realRoot / path);
int result = ::chown( wrapped.c_str(), owner, group);
if( result < 0 )
return -errno;
return result;
}
示例11: write
int FuseContext::write (const char *path,
const char *buf,
size_t bufsize,
off_t offset,
struct fuse_file_info *fi)
{
namespace fs = boost::filesystem;
Path_t wrapped = (m_realRoot / path);
// if fi has a file handle then we simply read from the file handle
if( fi->fh )
{
RefPtr<FileContext> file = m_openedFiles[fi->fh];
if(file)
{
int result = ::pwrite(file->fd(),buf,bufsize,offset);
if( result < 0 )
return -errno;
else
{
file->mark();
return result;
}
}
else
return -EBADF;
}
else
{
// otherwise open the file
int result = ::open( wrapped.c_str(), O_WRONLY );
if( result < 0 )
return -errno;
// get the file handle
int fh = result;
// perform the write
result = ::pwrite(fh,buf,bufsize,offset);
// close the file
::close(fh);
// check for error
if( result < 0 )
return -errno;
// increment the version
m_backend->db().incrementVersion( Path_t(path) );
return result;
}
}
示例12: chmod
int FuseContext::chmod (const char *path, mode_t mode)
{
namespace fs = boost::filesystem;
Path_t wrapped = m_realRoot / path;
// if it's not a directory
int result = ::chmod( wrapped.c_str(), mode );
if( result < 0 )
return -errno;
return result;
}
示例13: truncate
int FuseContext::truncate (const char *path, off_t length)
{
namespace fs = boost::filesystem;
Path_t wrapped = (m_realRoot / path).string();
int result = ::truncate( wrapped.c_str(), length );
if( result < 0 )
return -errno;
// update metadata
m_backend->db().incrementVersion( Path_t(path) );
return result;
}
示例14: setxattr
int FuseContext::setxattr (const char *path,
const char *key,
const char *value,
size_t bufsize,
int flags)
{
Path_t wrapped = m_realRoot / path;
int result = ::setxattr( wrapped.c_str(), key, value, bufsize, flags );
if( result < 0 )
return -errno;
return result;
}
示例15: open
int FuseContext::open (const char *path, struct fuse_file_info *fi)
{
namespace fs = boost::filesystem;
Path_t wrapped = m_realRoot / path;
// first we make sure that the file exists
Path_t parent = wrapped.parent_path();
Path_t filename = wrapped.filename();
if( !fs::exists(parent) )
return -ENOENT;
// make sure that the file exists, if it doesn't exist check for the
// O_CREAT flag
if( !fs::exists(wrapped) )
{
if( fi->flags | O_CREAT )
return this->create(path,0777,fi);
else
return -EEXIST;
}
// open the file
int result = ::open( wrapped.c_str(), fi->flags );
if( result < 0 )
return -errno;
// create a file descriptor for the opened file
int os_fd = result;
int my_fd = -1;
try
{
my_fd = m_openedFiles.registerFile( Path_t(path) ,os_fd);
result = 0;
}
catch( const std::exception& ex )
{
my_fd = -1;
result = -ENOMEM;
::close(os_fd);
std::cerr << "FuseContext::open"
<< "\n path: " << path
<< "\n real: " << wrapped
<< "\n err: " << ex.what();
}
fi->fh = my_fd;
return result;
}