create media settings directory before saving default nodes

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22837 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval 2007-11-05 21:54:12 +00:00
parent a00a1f4144
commit 8bef760f81

View File

@ -3,14 +3,15 @@
* Distributed under the terms of the MIT License.
*/
#include <Application.h>
#include <OS.h>
#include <Directory.h>
#include <File.h>
#include <FindDirectory.h>
#include <MediaNode.h>
#include <MediaRoster.h>
#include <OS.h>
#include <Path.h>
#include <TimeSource.h>
#include <string.h>
#include <storage/File.h>
#include <storage/FindDirectory.h>
#include <storage/Path.h>
#include "DefaultManager.h"
#include "DormantNodeManager.h"
#include "NodeManager.h"
@ -36,7 +37,8 @@ const char *kDefaultManagerFlavorName = "be:_flavor_name";
const char *kDefaultManagerPath = "be:_path";
const char *kDefaultManagerInput = "be:_input_id";
const char *kDefaultManagerSettings = "Media/MDefaultManager";
const char *kDefaultManagerSettingsDirectory = "Media";
const char *kDefaultManagerSettingsFile = "MDefaultManager";
DefaultManager::DefaultManager()
@ -73,7 +75,8 @@ DefaultManager::LoadState()
if((err = find_directory(B_USER_SETTINGS_DIRECTORY, &path))!=B_OK)
return err;
path.Append(kDefaultManagerSettings);
path.Append(kDefaultManagerSettingsDirectory);
path.Append(kDefaultManagerSettingsFile);
BFile file(path.Path(), B_READ_ONLY);
@ -110,10 +113,12 @@ DefaultManager::SaveState(NodeManager *node_manager)
status_t err = B_OK;
BPath path;
BList list;
if((err = find_directory(B_USER_SETTINGS_DIRECTORY, &path))!=B_OK)
if ((err = find_directory(B_USER_SETTINGS_DIRECTORY, &path, true)) != B_OK)
return err;
path.Append(kDefaultManagerSettings);
path.Append(kDefaultManagerSettingsDirectory);
if ((err = create_directory(path.Path(), 0755)) != B_OK)
return err;
path.Append(kDefaultManagerSettingsFile);
BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE);