bool XLinuxFile::Exists() const { StatHelper statHlp; VError verr=statHlp.Stat(fPath); // Check for existence then that it is a "regular" file and nothing else (WAK0073807). if(verr==VE_OK && statHlp.IsRegular()) return true; return false; //The file may exist but we can't access it. Let's pretend it doesn't exist ! }
VError XLinuxFile::GetSize(sLONG8 *outSize) const { if(outSize==NULL) return VE_INVALID_PARAMETER; StatHelper statHlp; VError verr=statHlp.Stat(fPath); if(verr!=VE_OK) return verr; *outSize=statHlp.GetSize(); return VE_OK; }
VError XLinuxFile::GetFileAttributes(EFileAttributes &outFileAttributes) const { //FATT_LockedFile = 1, <- on aimerait bien le savoir :) Creuser la piste mode readonly sur fd et perms ? //FATT_HidenFile = 2 <- pas de fichier caché sous Linux // Hidden files still no supported. (Check for a file name starting with a dot "." ?) StatHelper statHelper; XBOX::VError error; outFileAttributes = 0; if ((error = statHelper.Stat(fPath)) == XBOX::VE_OK && !statHelper.ProcessCanWrite()) outFileAttributes |= FATT_LockedFile; return error; }
bool XLinuxFile::IsAliasFile(bool* outIsValidAlias) const { StatHelper statHlp; VError verr=statHlp.Stat(fPath); if(verr!=VE_OK) return false; if(statHlp.IsLink()) { if(outIsValidAlias!=NULL) *outIsValidAlias=statHlp.Access(fPath); return true; } return false; }
//There is no creation time on Linux, but there is a status change time (modification of file's inode). VError XLinuxFile::GetTimeAttributes(VTime* outLastModification, VTime* outLastStatusChange, VTime* outLastAccess) const { StatHelper statHlp; VError verr=statHlp.Stat(fPath); if(verr!=VE_OK) return verr; if(outLastAccess!=NULL) outLastAccess->FromTime(statHlp.GetLastAccess()); if(outLastModification!=NULL) outLastModification->FromTime(statHlp.GetLastModification()); if(outLastStatusChange!=NULL) outLastStatusChange->FromTime(statHlp.GetLastStatusChange()); return VE_OK; }
VError XLinuxFile::GetVolumeFreeSpace(sLONG8* outFreeBytes, sLONG8* outTotalBytes, bool inWithQuotas) const { if(outFreeBytes==NULL && outTotalBytes==NULL) return VE_INVALID_PARAMETER; //We didn't failed nor succeed. Let's say we failed ! //jmo - todo : verifier si ca marche correctement avec les quotas utilisateur StatHelper statHlp; VError verr=statHlp.SetFlags(StatHelper::withFileSystemStats).Stat(fPath); if(verr!=VE_OK) return verr; sLONG8 freeBlocks=(inWithQuotas ? statHlp.GetFsAvailableBlocks() : statHlp.GetFsFreeBlocks()); sLONG8 totalBlocks=statHlp.GetFsTotalBlocks(); sLONG8 blockSize=statHlp.GetFsBlockSize(); if(outFreeBytes!=NULL) *outFreeBytes=freeBlocks*blockSize; if(outTotalBytes!=NULL) *outTotalBytes=totalBlocks*blockSize; return VE_OK; }
VError CopyHelper::DoInit(const PathBuffer& inSrc, const PathBuffer& inDst) { OpenHelper srcOpnHlp; VError verr=srcOpnHlp.SetFileAccess(FA_READ).Open(inSrc, &fSrcFd); if(verr!=VE_OK) return verr; StatHelper srcStats; verr=srcStats.Stat(fSrcFd); if(verr!=VE_OK) return verr; fSrcSize=srcStats.GetSize(); OpenHelper dstOpnHlp; verr=dstOpnHlp.SetFileAccess(FA_READ_WRITE).SetFileOpenOpts(FO_CreateIfNotFound).Open(inDst, &fDstFd); return verr; }
PathBuffer* ReaddirHelper::Next(PathBuffer* outNextPath, FileIteratorOptions inWanted, FileIteratorOptions* outFound) { outNextPath=Next(outNextPath); if(outNextPath==NULL) return NULL; if(!outNextPath->IsDotOrDotDot()) { StatHelper statHlp; if(inWanted&FI_RESOLVE_ALIASES) statHlp.SetFlags(StatHelper::followLinks); statHlp.Stat(*outNextPath); //Unless we prefer to follow them, links are exposed as special files if(inWanted&FI_WANT_FILES && (statHlp.IsRegular() || statHlp.IsLink())) { if(outFound!=NULL) *outFound=FI_WANT_FILES; return outNextPath; } if(inWanted&FI_WANT_FOLDERS && statHlp.IsDir()) { if(outFound!=NULL) *outFound=FI_WANT_FOLDERS; return outNextPath; } } //We didn't found what we where looking for. Let's continue. return Next(outNextPath, inWanted, outFound); }