⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qfileinfo.cpp

📁 Trolltech公司发布的图形界面操作系统。可在qt-embedded-2.3.10平台上编译为嵌入式图形界面操作系统。
💻 CPP
📖 第 1 页 / 共 2 页
字号:
*/void QFileInfo::refresh() const{    QFileInfo *that = (QFileInfo*)this;		// Mutable function    delete that->fic;    that->fic = 0;}/*!    \fn bool QFileInfo::caching() const    Returns TRUE if caching is enabled; otherwise returns FALSE.    \sa setCaching(), refresh()*//*!    If \a enable is TRUE, enables caching of file information. If \a    enable is FALSE caching is disabled.    When caching is enabled, QFileInfo reads the file information from    the file system the first time it's needed, but generally not    later.    Caching is enabled by default.    \sa refresh(), caching()*/void QFileInfo::setCaching( bool enable ){    if ( cache == enable )	return;    cache = enable;    if ( cache ) {	delete fic;	fic = 0;    }}/*!    Returns the file name, including the path (which may be absolute    or relative).    \sa isRelative(), absFilePath()*/QString QFileInfo::filePath() const{    return fn;}/*!    Returns the base name of the file.    If \a complete is FALSE (the default) the base name consists of    all characters in the file name up to (but not including) the \e    first '.' character.    If \a complete is TRUE the base name consists of all characters in    the file up to (but not including) the \e last '.' character.    The path is not included in either case.    Example:    \code	QFileInfo fi( "/tmp/archive.tar.gz" );	QString base = fi.baseName();  // base = "archive"	base = fi.baseName( TRUE );    // base = "archive.tar"    \endcode    \sa fileName(), extension()*/QString QFileInfo::baseName( bool complete ) const{    QString tmp = fileName();    int pos = complete ? tmp.findRev( '.' ) : tmp.find( '.' );    if ( pos == -1 )	return tmp;    else	return tmp.left( pos );}/*!    Returns the file's extension name.    If \a complete is TRUE (the default), extension() returns the    string of all characters in the file name after (but not    including) the first '.'  character.    If \a complete is FALSE, extension() returns the string of all    characters in the file name after (but not including) the last '.'    character.    Example:    \code	QFileInfo fi( "/tmp/archive.tar.gz" );	QString ext = fi.extension();  // ext = "tar.gz"	ext = fi.extension( FALSE );   // ext = "gz"    \endcode    \sa fileName(), baseName()*/QString QFileInfo::extension( bool complete ) const{    QString s = fileName();    int pos = complete ? s.find( '.' ) : s.findRev( '.' );    if ( pos < 0 )	return QString::fromLatin1( "" );    else	return s.right( s.length() - pos - 1 );}/*!    Returns the file's path as a QDir object.    If the QFileInfo is relative and \a absPath is FALSE, the QDir    will be relative; otherwise it will be absolute.    \sa dirPath(), filePath(), fileName(), isRelative()*/#ifndef QT_NO_DIRQDir QFileInfo::dir( bool absPath ) const{    return QDir( dirPath(absPath) );}#endif/*!    Returns TRUE if the file is readable; otherwise returns FALSE.    \sa isWritable(), isExecutable(), permission()*/bool QFileInfo::isReadable() const{#ifdef Q_WS_WIN    return qt_file_access( fn, R_OK ) && permission( ReadUser );#else    return qt_file_access( fn, R_OK );#endif}/*!    Returns TRUE if the file is writable; otherwise returns FALSE.    \sa isReadable(), isExecutable(), permission()*/bool QFileInfo::isWritable() const{#ifdef Q_WS_WIN    return qt_file_access( fn, W_OK ) && permission( WriteUser );#else    return qt_file_access( fn, W_OK );#endif}/*!    Returns TRUE if the file is executable; otherwise returns FALSE.    \sa isReadable(), isWritable(), permission()*/bool QFileInfo::isExecutable() const{#ifdef Q_WS_WIN    return qt_file_access( fn, X_OK ) && permission( ExeUser );#else    return qt_file_access( fn, X_OK );#endif}#ifndef Q_WS_WINbool QFileInfo::isHidden() const{    return fileName()[ 0 ] == QChar( '.' );}#endif/*!    Returns TRUE if the file path name is relative. Returns FALSE if    the path is absolute (e.g. under Unix a path is absolute if it    begins with a "/").*/#ifndef QT_NO_DIRbool QFileInfo::isRelative() const{    return QDir::isRelativePath( fn );}/*!    Converts the file's path to an absolute path.    If it is already absolute, nothing is done.    \sa filePath(), isRelative()*/bool QFileInfo::convertToAbs(){    if ( isRelative() )	fn = absFilePath();    return QDir::isRelativePath( fn );}#endif/*!    Returns the file size in bytes, or 0 if the file does not exist or    if the size is 0 or if the size cannot be fetched.*/#if defined(QT_ABI_QT4)QIODevice::Offset QFileInfo::size() const#elseuint QFileInfo::size() const#endif{    if ( !fic || !cache )	doStat();    if ( fic )#if defined(QT_ABI_QT4)	return (QIODevice::Offset)fic->st.st_size;#elif defined(QT_LARGEFILE_SUPPORT)	return (uint)fic->st.st_size > UINT_MAX ? UINT_MAX : (uint)fic->st.st_size;#else	return (uint)fic->st.st_size;#endif    else	return 0;}/*!    Returns the date and time when the file was created.    On platforms where this information is not available, returns the    same as lastModified().    \sa created() lastModified() lastRead()*/QDateTime QFileInfo::created() const{    QDateTime dt;    if ( !fic || !cache )	doStat();    if ( fic && fic->st.st_ctime != 0 ) {	dt.setTime_t( fic->st.st_ctime );	return dt;    } else {	return lastModified();    }}/*!    Returns the date and time when the file was last modified.    \sa created() lastModified() lastRead()*/QDateTime QFileInfo::lastModified() const{    QDateTime dt;    if ( !fic || !cache )	doStat();    if ( fic )	dt.setTime_t( fic->st.st_mtime );    return dt;}/*!    Returns the date and time when the file was last read (accessed).    On platforms where this information is not available, returns the    same as lastModified().    \sa created() lastModified() lastRead()*/QDateTime QFileInfo::lastRead() const{    QDateTime dt;    if ( !fic || !cache )	doStat();    if ( fic && fic->st.st_atime != 0 ) {	dt.setTime_t( fic->st.st_atime );	return dt;    } else {	return lastModified();    }}#ifndef QT_NO_DIR/*!    Returns the absolute path including the file name.    The absolute path name consists of the full path and the file    name. On Unix this will always begin with the root, '/',    directory. On Windows this will always begin 'D:/' where D is a    drive letter, except for network shares that are not mapped to a    drive letter, in which case the path will begin '//sharename/'.    This function returns the same as filePath(), unless isRelative()    is TRUE.    If the QFileInfo is empty it returns QDir::currentDirPath().    This function can be time consuming under Unix (in the order of    milliseconds).    \sa isRelative(), filePath()*/QString QFileInfo::absFilePath() const{    QString tmp;    if ( QDir::isRelativePath(fn)#if defined(Q_OS_WIN32)	 && fn[1] != ':'#endif	 ) {	tmp = QDir::currentDirPath();	tmp += '/';    }    tmp += fn;    makeAbs( tmp );    return QDir::cleanDirPath( tmp );}/*! \internal    Detaches all internal data.*/void QFileInfo::detach(){    fn = QDeepCopy<QString>( fn );    if ( fic ) {	QFileInfoCache *cur = fic;	fic = new QFileInfoCache;	*fic = *cur;	delete cur;    }}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -