SVN commit 850279 by asimha:
Adding a static function to BinFileHelper to test if a file exists or
not. Useful for detecting and loading optional catalogs.
CCMAIL:
kstars-devel@...
M +13 -0 binfilehelper.cpp
M +5 -0 binfilehelper.h
--- trunk/KDE/kdeedu/kstars/kstars/binfilehelper.cpp #850278:850279
@@ -57,6 +57,19 @@
fields.clear();
}
+bool BinFileHelper::testFileExists( const QString &fileName ) {
+ QString FilePath = KStandardDirs::locate( "appdata", fileName );
+ QByteArray b = FilePath.toAscii();
+ const char *filepath = b.data();
+ FILE *f = KDE_fopen(filepath, "rb");
+ if( f ) {
+ fclose( f );
+ return true;
+ }
+ else
+ return false;
+}
+
FILE *BinFileHelper::openFile(const QString &fileName) {
QString FilePath = KStandardDirs::locate( "appdata", fileName );
init();
--- trunk/KDE/kdeedu/kstars/kstars/binfilehelper.h #850278:850279
@@ -64,6 +64,11 @@
*/
~BinFileHelper();
+
+ /**
+ *@short Checks if a file exists. WARNING: Might be incompatible in other locales
+ */
+ static bool testFileExists( const QString &fileName );
/**
*WARNING: This function may not be compatible in other locales, because it calls QString::toAscii
_______________________________________________
Kstars-devel mailing list
Kstars-devel@...
https://mail.kde.org/mailman/listinfo/kstars-devel