// a settings file class.
// Copyright (c) 1999-2000, Be Incoporated. All Rights Reserved.

#ifndef _APPPREFS_H_
#define _APPPREFS_H_

#include <Message.h>
#include <FindDirectory.h>
#include <Path.h>

struct attr_info;

class BAppPrefs : public BMessage {
public :
	BAppPrefs(char const*leafname=NULL,char const*basename=NULL,directory_which dir=B_USER_SETTINGS_DIRECTORY);
	BAppPrefs(const BMessage&,char const*leafname=NULL,char const*basename=NULL,directory_which dir=B_USER_SETTINGS_DIRECTORY);

	BAppPrefs(const BAppPrefs&);
	BAppPrefs&operator=(const BAppPrefs&);

	virtual ~BAppPrefs();

	status_t InitCheck() const;

	status_t SetTo(char const*leafname=NULL,char const*basename=NULL,directory_which dir=B_USER_SETTINGS_DIRECTORY);
	const char* Path() const;

	status_t Load(int32 flags=0);
	status_t Save(int32 flags=0) const;

private:
	virtual status_t Perform(perform_code d, void *arg);

	void _CtorInit(char const*leafname=NULL,char const*basename=NULL,directory_which dir=B_USER_SETTINGS_DIRECTORY);

	static status_t _StoreAttributes(BMessage const*m,BFile*f,const char*basename="");
	static status_t _ExtractAttribute(BMessage*m,BFile*f,const char*full_name,char*partial_name,attr_info*ai);
	static bool _SupportsType(type_code);

	status_t check;
	BPath path;

	void*_ReservedAppPrefs;
};

#endif

