本文整理汇总了C++中PathBuffer类的典型用法代码示例。如果您正苦于以下问题:C++ PathBuffer类的具体用法?C++ PathBuffer怎么用?C++ PathBuffer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PathBuffer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Open
VError OpenHelper::Open(const PathBuffer& inPath, FileDescSystemRef* outFd)
{
if(GetFileAccess()==FA_MAX)
return OpenMax(inPath.GetPath(), outFd);
bool failToGetLock=false; //(we don't care)
VError verr=OpenStd(inPath.GetPath(), outFd, &failToGetLock);
return verr;
}
示例2: CreateAlias
VError XLinuxFile::CreateAlias(const VFilePath &inTargetPath, const VFilePath *unused) const
{
PathBuffer targetPath;
targetPath.Init(inTargetPath);
LinkHelper lnkHlp;
VError verr=lnkHlp.Link(fPath, targetPath);
return verr;
}
示例3: sizeof
VFilePath VProcess::GetExecutableFilePath() const
{
VFilePath filePath;
#if VERSIONMAC
CFURLRef exeURL = ::CFBundleCopyExecutableURL( ::CFBundleGetMainBundle());
if (testAssert( exeURL != NULL ))
{
CFStringRef cfPath = ::CFURLCopyFileSystemPath( exeURL, kCFURLHFSPathStyle);
if (testAssert( cfPath != NULL ))
{
VString thepath;
thepath.MAC_FromCFString( cfPath);
thepath.Compose();
filePath.FromFullPath( thepath, FPS_SYSTEM);
::CFRelease( cfPath);
}
::CFRelease(exeURL );
}
#elif VERSIONWIN
// Get a path to the exe.
UniChar path[4096];
DWORD pathLength=0;
path[sizeof(path)/sizeof(UniChar)-2]=0;
pathLength = ::GetModuleFileNameW(NULL, path, sizeof(path));
if (testAssert(pathLength != 0 && !path[sizeof(path)/sizeof(UniChar)-2]))
{
VString thepath( path);
filePath.FromFullPath( thepath, FPS_SYSTEM);
}
#elif VERSION_LINUX
PathBuffer path;
VError verr=path.InitWithExe();
xbox_assert(verr==VE_OK);
path.ToPath(&filePath);
xbox_assert(verr==VE_OK);
#endif
return filePath;
}
示例4: Load
bool XLinuxLibrary::Load(const VFilePath &inFilePath)
{
VFile* soFile=RetainExecutableFile(inFilePath);
VFilePath soPath=soFile->GetPath();
soFile->Release();
PathBuffer tmpBuf;
tmpBuf.Init(soPath);
if(fLib.Open(tmpBuf)!=VE_OK)
return false;
return true;
}
示例5: Rename
VError XLinuxFile::Rename(const VFilePath& inDstPath, VFile** outFile) const
{
if(outFile!=NULL)
*outFile=NULL;
PathBuffer dstPath;
dstPath.Init(inDstPath);
RenameHelper rnmHlp;
VError verr=rnmHlp.Rename(fPath, dstPath);
if(verr==VE_OK && outFile!=NULL)
*outFile=new VFile(inDstPath);
return verr;
}
示例6: fOpts
ReaddirHelper::ReaddirHelper(const PathBuffer& inFolderPath, FileIteratorOptions inOptions) :
fOpts(inOptions), fDir(NULL), fPath(inFolderPath)
{
memset(&fEntry, 0, sizeof(fEntry));
//If it fails for any reason (inFolderPath is a file for ex.), opendir returns NULL.
fDir=opendir(inFolderPath.GetPath());
}
示例7: MakeDir
VError MkdirHelper::MakeDir(const PathBuffer& inPath) const
{
mode_t modeFlags=PERM_755;
int res=mkdir(inPath.GetPath(), modeFlags);
return (res==0) ? VE_OK : MAKE_NATIVE_VERROR(errno);
}
示例8: tmpPath
VError XLinuxFile::Copy(const VFilePath& inDestination, VFile** outFile, FileCopyOptions inOptions ) const
{
VFilePath tmpPath(inDestination);
if(tmpPath.IsFolder())
{
VStr255 name; //jmo - todo : NAME_MAX ?
fOwner->GetName(name);
tmpPath.SetFileName(name);
}
PathBuffer dstPath;
dstPath.Init(tmpPath);
CopyHelper cpHlp;
return cpHlp.Copy(fPath, dstPath);
}
示例9: fOpts
XLinuxFileIterator::XLinuxFileIterator(const VFolder *inFolder, FileIteratorOptions inOptions)
: fOpts(0)
, fIt(NULL)
, fFileSystem( inFolder->GetFileSystem())
{
//Because Next() returns a VFile ptr, we want files and no folders.
fOpts=inOptions;
fOpts|=FI_WANT_FILES;
fOpts&=~FI_WANT_FOLDERS;
VFilePath tmpPath;
inFolder->GetPath(tmpPath);
PathBuffer path;
path.Init(tmpPath);
fIt=new FsIterator(path, inOptions);
}
示例10: dstPath
VError XLinuxFile::Move(const VFilePath& inDestinationPath, VFileSystem *inDestinationFileSystem, VFile** outFile, FileCopyOptions /*inOptions*/) const
{
VFilePath dstPath(inDestinationPath);
if (dstPath.IsFolder())
{
VStr255 name; //jmo - todo : NAME_MAX ?
fOwner->GetName(name);
dstPath.SetFileName(name);
}
PathBuffer pathBuffer;
pathBuffer.Init(dstPath);
//First we try to rename the file...
VError verr;
{
RenameHelper rnmHlp;
verr=rnmHlp.Rename(fPath, pathBuffer);
}
//If Rename() fails because src and dst are not on the same fs, we try a Copy()
if(verr!=VE_OK && IS_NATIVE_VERROR(verr) && NATIVE_ERRCODE_FROM_VERROR(verr)==EXDEV)
{
CopyHelper cpHlp;
verr = cpHlp.Copy(fPath, pathBuffer);
// it's a move not a copy, so one must delete the source after a sucessful copy
if (verr == VE_OK)
{
int res=unlink(fPath.GetPath());
verr = (res==0) ? VE_OK : MAKE_NATIVE_VERROR(errno);
}
}
if (outFile != NULL)
{
*outFile = (verr == VE_OK) ? new VFile( dstPath, inDestinationFileSystem) : NULL;
}
return verr;
}
示例11: newPath
VError XLinuxFile::Rename(const VString& inName, VFile** outFile) const
{
//jmo - todo : we should check that inName < NAME_MAX or use PathBuffer
VFilePath newPath(fOwner->GetPath());
newPath.SetFileName(inName);
PathBuffer dstPath;
dstPath.Init(newPath);
RenameHelper rnmHlp;
VError verr=rnmHlp.Rename(fPath, dstPath);
if (outFile != NULL)
{
*outFile = (verr == VE_OK) ? new VFile( newPath, fOwner->GetFileSystem()) : NULL;
}
return verr;
}
示例12: ProcessCanWrite
//static
bool OpenHelper::ProcessCanWrite(const PathBuffer& inPath)
{
int fd=open(const_cast<char*>(inPath.GetPath()), O_WRONLY);
if(fd>0)
{
close(fd);
return true;
}
return false;
}
示例13: Init
VError PathBuffer::Init(const VString& inPath, Mode inMode)
{
PathBuffer tmpBuf;
char* buf=NULL;
//If we want the real path of the file, we perform the UTF8 conversion in a tmp buffer and then the realpath transform in 'this'
if(inMode==withRealPath)
buf=tmpBuf.fPath;
else
buf=fPath;
VSize n=inPath.ToBlock(buf, sizeof(fPath), VTC_UTF_8, false /*without trailing 0*/, false /*no lenght prefix*/);
if(n==sizeof(fPath))
return VE_INVALID_PARAMETER; //UTF8 path is more than PATH_MAX bytes long ; we do not support that.
buf[n]=0;
if(inMode==withRealPath)
return tmpBuf.RealPath(this);
return VE_OK;
}
示例14: Stat
VError StatHelper::Stat(const PathBuffer& inPath)
{
int res=(fFlags&followLinks) ? stat(inPath.GetPath(), &fStat) : lstat(inPath.GetPath(), &fStat);
if(res==ENOENT || res==ENOTDIR)
fDoesNotExist=true; //We are sure that the file doesn't exists
if(res!=0)
return MAKE_NATIVE_VERROR(errno);
fDoesExist=true; //We are sure that the file exists
if(fFlags&withFileSystemStats)
{
//I put stats on file systems here because they are obtained through a file of the fs.
res=statfs(inPath.GetPath(), &fFsStat);
if(res!=0)
return MAKE_NATIVE_VERROR(errno);
}
return VE_OK;
}
示例15: Touch
VError TouchHelper::Touch(const PathBuffer& inPath, VTime inAccessTime, VTime inModificationTime) const
{
struct utimbuf buf;
memset(&buf, 0, sizeof(buf));
buf.actime=XBoxToUnixTime(inAccessTime);
buf.modtime=XBoxToUnixTime(inModificationTime);
int res=utime(inPath.GetPath(), &buf);
if(res<0)
return MAKE_NATIVE_VERROR(errno);
return VE_OK;
}