[Okular-devel] Readable file test changes

David Palacio dpalacio at orbitalibre.org
Sun Apr 17 22:37:03 CEST 2011


Greetings Okular developers,

I have an Okular generator that opens directories as documents. Each
image in the directory is a page in the document. Currently it is
unusable because directories always fail a test made for regular files.
Here I propose a patch to fix this issue. Please consider it and thank
you for reading.

Regards,
David Palacio

-------------- next part --------------
Index: core/document.cpp
===================================================================
--- core/document.cpp	(revisi?n: 1227922)
+++ core/document.cpp	(copia de trabajo)
@@ -1538,9 +1538,9 @@
         if ( mime.count() <= 0 )
             return false;
 
-        // docFile is always local so we can use QFile on it
-        QFile fileReadTest( docFile );
-        if ( !fileReadTest.open( QIODevice::ReadOnly ) )
+        // docFile is always local so we can use QFileInfo on it
+        QFileInfo fileReadTest( docFile );
+        if ( fileReadTest.isFile() && !fileReadTest.isReadable() )
         {
             d->m_docFileName.clear();
             return false;
@@ -1553,7 +1553,6 @@
         QString fn = url.fileName();
         document_size = fileReadTest.size();
         fn = QString::number( document_size ) + '.' + fn + ".xml";
-        fileReadTest.close();
         QString newokular = "okular/docdata/" + fn;
         QString newokularfile = KStandardDirs::locateLocal( "data", newokular );
         if ( !QFile::exists( newokularfile ) )


More information about the Okular-devel mailing list