#include #include #include "Config.h" Config::Config () { verbose = false; daemon = true; will_save = false; } // !! handle file status void Config::Load () { if ( configPath == NULL ) configPath = BString( "/boot/home/config/settings/Pogger/" ); BString filename = BString(configPath); filename.Append("settings"); BFile* file = new BFile( filename.String(), B_READ_ONLY ); status_t result = file->InitCheck(); BMessage storage; storage.Unflatten( file ); if ( mimetype == NULL) mimetype = BString( storage.GetString("mimetype", "text/xml") ); if ( outDir == NULL) outDir = BString( storage.GetString("outDir", "/boot/home/feeds/") ); // if ( cacheDir == NULL) // cacheDir = BString( storage.GetString("cacheDir", "/boot/home/config/cache/Pogger/") ); delete file; } // !! handle file status void Config::Save () { if ( configPath == NULL ) configPath = BString( "/boot/home/config/settings/Pogger/" ); BPath* cfgPath = new BPath( configPath.String(), NULL, true ); BEntry* cfgEntry = new BEntry( cfgPath->Path() ); BDirectory* cfgDir = new BDirectory; cfgDir->CreateDirectory(cfgPath->Path(), NULL); if ( cfgEntry->Exists() == false ) cfgDir->CreateDirectory( cfgPath->Path(), NULL ); BMessage storage; BString filename = BString( configPath ).Append("/settings"); BFile* file = new BFile( filename.String(), B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE ); status_t result = file->InitCheck(); storage.AddString( "mimetype", mimetype.String() ); storage.AddString( "outDir", outDir.String() ); // storage.AddString( "cacheDir", cacheDir.String() ); storage.Flatten( file ); }