applied patch by Maurice Kalinowski:
* Add check whether directory to store settings exists. If not, create it. * Use global constant (like in DefaultManager.cpp) for path/file names. * Cleaned up a little bit and made debug output only appear in case debugging is turned on (meaning printf->TRACE). -> Fixes #1531. (I added a few more error checks to the code, maybe there should be even more...) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24089 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
c789abb0e8
commit
c067ed4ea4
@ -2,15 +2,21 @@
|
||||
* Copyright 2003, Jérôme Duval. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#include <Application.h>
|
||||
#include <Autolock.h>
|
||||
#include <MediaFiles.h>
|
||||
#include <string.h>
|
||||
#include <storage/FindDirectory.h>
|
||||
#include <storage/Path.h>
|
||||
#include "debug.h"
|
||||
#include "MMediaFilesManager.h"
|
||||
#include "MediaSounds.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include <Application.h>
|
||||
#include <Autolock.h>
|
||||
#include <Directory.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <MediaFiles.h>
|
||||
#include <Path.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
const char *kMediaFilesManagerSettingsDirectory = "Media";
|
||||
const char *kMediaFilesManagerSettingsFile = "MMediaFilesManager";
|
||||
|
||||
|
||||
MMediaFilesManager::MMediaFilesManager()
|
||||
@ -40,6 +46,7 @@ MMediaFilesManager::MMediaFilesManager()
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
MMediaFilesManager::~MMediaFilesManager()
|
||||
{
|
||||
CALLED();
|
||||
@ -91,13 +98,15 @@ status_t
|
||||
MMediaFilesManager::LoadState()
|
||||
{
|
||||
CALLED();
|
||||
status_t err = B_OK;
|
||||
BPath path;
|
||||
if ((err = find_directory(B_USER_SETTINGS_DIRECTORY, &path)) != B_OK)
|
||||
status_t err = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
|
||||
if (err >= B_OK)
|
||||
err = path.Append(kMediaFilesManagerSettingsDirectory);
|
||||
if (err >= B_OK)
|
||||
err = path.Append(kMediaFilesManagerSettingsFile);
|
||||
if (err < B_OK)
|
||||
return err;
|
||||
|
||||
path.Append("Media/MMediaFilesManager");
|
||||
|
||||
BFile file(path.Path(), B_READ_ONLY);
|
||||
|
||||
uint32 category_count;
|
||||
@ -160,13 +169,19 @@ status_t
|
||||
MMediaFilesManager::SaveState()
|
||||
{
|
||||
CALLED();
|
||||
status_t err = B_OK;
|
||||
BPath path;
|
||||
if ((err = find_directory(B_USER_SETTINGS_DIRECTORY, &path)) != B_OK)
|
||||
status_t err = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
|
||||
if (err >= B_OK)
|
||||
err = path.Append(kMediaFilesManagerSettingsDirectory);
|
||||
if (err >= B_OK) {
|
||||
err = create_directory(path.Path(),
|
||||
S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
|
||||
}
|
||||
if (err >= B_OK)
|
||||
err = path.Append(kMediaFilesManagerSettingsFile);
|
||||
if (err < B_OK)
|
||||
return err;
|
||||
|
||||
path.Append("Media/MMediaFilesManager");
|
||||
|
||||
BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE);
|
||||
uint32 zero = 0;
|
||||
|
||||
@ -206,11 +221,10 @@ void
|
||||
MMediaFilesManager::Dump()
|
||||
{
|
||||
BAutolock lock(fLocker);
|
||||
printf("\n");
|
||||
|
||||
/* for each type, the registry map contains a map of item/entry_ref
|
||||
*/
|
||||
printf("MMediaFilesManager: registry map follows\n");
|
||||
TRACE("MMediaFilesManager: registry map follows\n");
|
||||
BString *type = NULL;
|
||||
Map<BString, entry_ref> *map;
|
||||
BString *item = NULL;
|
||||
@ -221,13 +235,11 @@ MMediaFilesManager::Dump()
|
||||
for (map->Rewind(); map->GetNext(&ref);) {
|
||||
map->GetCurrentKey(&item);
|
||||
BPath path(ref);
|
||||
printf(" type \"%s\", item \"%s\", path \"%s\"\n",
|
||||
TRACE(" type \"%s\", item \"%s\", path \"%s\"\n",
|
||||
type->String(), item->String(), (path.InitCheck() == B_OK) ? path.Path() : "INVALID");
|
||||
}
|
||||
}
|
||||
printf("MMediaFilesManager: list end\n");
|
||||
printf("\n");
|
||||
|
||||
TRACE("MMediaFilesManager: list end\n");
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user