author | zecke <zecke> | 2002-09-15 22:19:08 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-09-15 22:19:08 (UTC) |
commit | aabe567e96d040c483b947f5758a1405cc312fdc (patch) (side-by-side diff) | |
tree | ceb8ebba2384f1737277c0dfb89256eaa2ac1717 /libopie/ofileselector/olocallister.cpp~ | |
parent | 09561ee29b5288e02e513172fc590d27e9e09333 (diff) | |
download | opie-aabe567e96d040c483b947f5758a1405cc312fdc.zip opie-aabe567e96d040c483b947f5758a1405cc312fdc.tar.gz opie-aabe567e96d040c483b947f5758a1405cc312fdc.tar.bz2 |
add files
Diffstat (limited to 'libopie/ofileselector/olocallister.cpp~') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie/ofileselector/olocallister.cpp~ | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/libopie/ofileselector/olocallister.cpp~ b/libopie/ofileselector/olocallister.cpp~ new file mode 100644 index 0000000..b0e5410 --- a/dev/null +++ b/libopie/ofileselector/olocallister.cpp~ @@ -0,0 +1,97 @@ +#include <qdir.h> +#include <qfileinfo.h> +#include <qmap.h> + +#include <qpe/mimetype.h> + +#include "ofileselector.h" +#include "olocallister.h" + +OLocalLister::OLocalLister( OFileSelector* file ) + : OLister( file ) +{ +} +OLocalLister::~OLocalLister() { +} + +QMap<QString, QString> OLocalLister::mimeTypes( const QString& curDir ) { + QMap<QString, QString> mimes; + + // let's find possible mimetypes + QDir dir( curDir ); + dir.setFilter( QDir::Files | QDir::Readable ); + dir.setSorting( QDir::Size ); + + const QFileInfoList *list = dir.entryInfoList(); + QFileInfoListIterator it( *list ); + QFileInfo *fi; + + while( (fi=it.current() ) ) { + if( fi->extension() == QString::fromLatin1("desktop") ){ + ++it; + continue; + } + MimeType type( fi->absFilePath() ); + + if( !mimes.contains( type.id() ) ){ + mimes.insert( type.id(), type.id() ); + } + + ++it; + } + + return mimes; +} +void OLocalLister::reparse( const QString& path ) { + QString currentMimeType; + QDir dir( path ); + + dir.setSorting( view()->sorting() ); + dir.setFilter( view()->filter() ); + + // now go through all files + const QFileInfoList *list = dir.entryInfoList(); + QFileInfoListIterator it( *list ); + QFileInfo *fi; + + while( (fi=it.current() ) ){ + + if( fi->fileName() == QString::fromLatin1("..") || + fi->fileName() == QString::fromLatin1(".") ){ + ++it; + continue; + } + if( fi->isSymLink() ){ + QString file = fi->dirPath( true ) + "/" + fi->readLink(); + /* + * 5 tries to prevent dos attack + */ + for( int i = 0; i<=4; i++) { + QFileInfo info( file ); + if( !info.exists() ){ + addSymlink( currentMimeType, fi, TRUE ); + break; + }else if( info.isDir() ){ + addDir( currentMimeType, fi, + TRUE ); + break; + }else if( info.isFile() ){ + addFile( currentMimeType, fi, TRUE ); + break; + }else if( info.isSymLink() ){ + file = info.dirPath(true ) + "/" + info.readLink() ; + break; + }else if( i == 4){ + addSymlink( currentMimeType, fi ); + } + } + + }else if( fi->isDir() ){ + addDir( currentMimeType, fi ); + }else if( fi->isFile() ){ + addFile( currentMimeType, fi ); + } + ++it; + } // of while loop +} + |