Diffstat (limited to 'qmake/tools/qfileinfo_unix.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | qmake/tools/qfileinfo_unix.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/qmake/tools/qfileinfo_unix.cpp b/qmake/tools/qfileinfo_unix.cpp index f7c3a97..364f219 100644 --- a/qmake/tools/qfileinfo_unix.cpp +++ b/qmake/tools/qfileinfo_unix.cpp @@ -121,195 +121,195 @@ QString QFileInfo::readLink() const r = QFile::decodeName(s); } #endif return r; } static const uint nobodyID = (uint) -2; /*! Returns the owner of the file. On Windows, on systems where files do not have owners, or if an error occurs, QString::null is returned. This function can be time consuming under Unix (in the order of milliseconds). \sa ownerId(), group(), groupId() */ QString QFileInfo::owner() const { passwd *pw = getpwuid( ownerId() ); if ( pw ) return QFile::decodeName( pw->pw_name ); return QString::null; } /*! Returns the id of the owner of the file. On Windows and on systems where files do not have owners this function returns ((uint) -2). \sa owner(), group(), groupId() */ uint QFileInfo::ownerId() const { if ( !fic || !cache ) doStat(); if ( fic ) return fic->st.st_uid; return nobodyID; } /*! Returns the group of the file. On Windows, on systems where files do not have groups, or if an error occurs, QString::null is returned. This function can be time consuming under Unix (in the order of milliseconds). \sa groupId(), owner(), ownerId() */ QString QFileInfo::group() const { struct group *gr = getgrgid( groupId() ); if ( gr ) return QFile::decodeName( gr->gr_name ); return QString::null; } /*! Returns the id of the group the file belongs to. On Windows and on systems where files do not have groups this function always returns (uint) -2. \sa group(), owner(), ownerId() */ uint QFileInfo::groupId() const { if ( !fic || !cache ) doStat(); if ( fic ) return fic->st.st_gid; return nobodyID; } /*! Tests for file permissions. The \a permissionSpec argument can be several flags of type \c PermissionSpec OR-ed together to check for permission combinations. On systems where files do not have permissions this function always returns TRUE. Example: \code QFileInfo fi( "/tmp/archive.tar.gz" ); if ( fi.permission( QFileInfo::WriteUser | QFileInfo::ReadGroup ) ) - qWarning( "I can change the file; my group can read the file."); + qWarning( "I can change the file; my group can read the file" ); if ( fi.permission( QFileInfo::WriteGroup | QFileInfo::WriteOther ) ) - qWarning( "The group or others can change the file!" ); + qWarning( "The group or others can change the file" ); \endcode \sa isReadable(), isWritable(), isExecutable() */ bool QFileInfo::permission( int permissionSpec ) const { if ( !fic || !cache ) doStat(); if ( fic ) { uint mask = 0; if ( permissionSpec & ReadUser ) mask |= S_IRUSR; if ( permissionSpec & WriteUser ) mask |= S_IWUSR; if ( permissionSpec & ExeUser ) mask |= S_IXUSR; if ( permissionSpec & ReadGroup ) mask |= S_IRGRP; if ( permissionSpec & WriteGroup ) mask |= S_IWGRP; if ( permissionSpec & ExeGroup ) mask |= S_IXGRP; if ( permissionSpec & ReadOther ) mask |= S_IROTH; if ( permissionSpec & WriteOther ) mask |= S_IWOTH; if ( permissionSpec & ExeOther ) mask |= S_IXOTH; if ( mask ) { return (fic->st.st_mode & mask) == mask; } else { #if defined(QT_CHECK_NULL) qWarning( "QFileInfo::permission: permissionSpec is 0" ); #endif return TRUE; } } else { return FALSE; } } void QFileInfo::doStat() const { QFileInfo *that = ((QFileInfo*)this); // mutable function if ( !that->fic ) that->fic = new QFileInfoCache; that->symLink = FALSE; struct stat *b = &that->fic->st; #if defined(Q_OS_UNIX) && defined(S_IFLNK) if ( ::lstat( QFile::encodeName(fn), b ) == 0 ) { if ( S_ISLNK( b->st_mode ) ) that->symLink = TRUE; else return; } #endif int r = ::stat( QFile::encodeName(fn), b ); if ( r != 0 && !that->symLink ) { delete that->fic; that->fic = 0; } } /*! Returns the file's path. If \a absPath is TRUE an absolute path is returned. \sa dir(), filePath(), fileName(), isRelative() */ #ifndef QT_NO_DIR QString QFileInfo::dirPath( bool absPath ) const { QString s; if ( absPath ) s = absFilePath(); else s = fn; int pos = s.findRev( '/' ); if ( pos == -1 ) { return QString::fromLatin1( "." ); } else { if ( pos == 0 ) return QString::fromLatin1( "/" ); return s.left( pos ); } } #endif /*! Returns the name of the file, excluding the path. Example: \code |