* Added find directory constants B_{BEOS|COMMON|USER}_DATA_DIRECTORY, which
currently points to /etc for the system, and dedicated "data" directories for common/user (the system directory should get a dedicated "data", too, though). * Added B_USER_CACHE_DIRECTORY (in config/cache). * These additions were discussed some years ago, but I just had a good reason to use them :-) * Coding style cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26990 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
6296f36bc3
commit
63c96ae5a5
@ -1,39 +1,20 @@
|
|||||||
//----------------------------------------------------------------------
|
/*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Copyright 2002-2008, Haiku Inc. All Rights Reserved.
|
||||||
// by the OpenBeOS license.
|
* Distributed under the terms of the MIT License.
|
||||||
//---------------------------------------------------------------------
|
|
||||||
/*!
|
|
||||||
\file FindDirectory.h
|
|
||||||
Declarations of find_directory() functions and associated types.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _FIND_DIRECTORY_H
|
#ifndef _FIND_DIRECTORY_H
|
||||||
#define _FIND_DIRECTORY_H
|
#define _FIND_DIRECTORY_H
|
||||||
|
|
||||||
|
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
#ifdef USE_OPENBEOS_NAMESPACE
|
|
||||||
namespace OpenBeOS {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
/* ---
|
// Per volume directories
|
||||||
Per volume directories. When asking for these
|
|
||||||
directories, a volume must be specified, or the call will assume
|
|
||||||
the boot volume.
|
|
||||||
--- */
|
|
||||||
|
|
||||||
B_DESKTOP_DIRECTORY = 0,
|
B_DESKTOP_DIRECTORY = 0,
|
||||||
B_TRASH_DIRECTORY,
|
B_TRASH_DIRECTORY,
|
||||||
|
|
||||||
/* ---
|
// System directories
|
||||||
BeOS directories. These are mostly accessed read-only.
|
|
||||||
--- */
|
|
||||||
|
|
||||||
B_BEOS_DIRECTORY = 1000,
|
B_BEOS_DIRECTORY = 1000,
|
||||||
B_BEOS_SYSTEM_DIRECTORY,
|
B_BEOS_SYSTEM_DIRECTORY,
|
||||||
B_BEOS_ADDONS_DIRECTORY,
|
B_BEOS_ADDONS_DIRECTORY,
|
||||||
@ -49,11 +30,9 @@ typedef enum {
|
|||||||
B_BEOS_TRANSLATORS_DIRECTORY,
|
B_BEOS_TRANSLATORS_DIRECTORY,
|
||||||
B_BEOS_MEDIA_NODES_DIRECTORY,
|
B_BEOS_MEDIA_NODES_DIRECTORY,
|
||||||
B_BEOS_SOUNDS_DIRECTORY,
|
B_BEOS_SOUNDS_DIRECTORY,
|
||||||
|
B_BEOS_DATA_DIRECTORY,
|
||||||
|
|
||||||
/* ---
|
// Common directories, shared among all users.
|
||||||
Common directories, shared among all users.
|
|
||||||
--- */
|
|
||||||
|
|
||||||
B_COMMON_DIRECTORY = 2000,
|
B_COMMON_DIRECTORY = 2000,
|
||||||
B_COMMON_SYSTEM_DIRECTORY,
|
B_COMMON_SYSTEM_DIRECTORY,
|
||||||
B_COMMON_ADDONS_DIRECTORY,
|
B_COMMON_ADDONS_DIRECTORY,
|
||||||
@ -73,13 +52,11 @@ typedef enum {
|
|||||||
B_COMMON_TRANSLATORS_DIRECTORY,
|
B_COMMON_TRANSLATORS_DIRECTORY,
|
||||||
B_COMMON_MEDIA_NODES_DIRECTORY,
|
B_COMMON_MEDIA_NODES_DIRECTORY,
|
||||||
B_COMMON_SOUNDS_DIRECTORY,
|
B_COMMON_SOUNDS_DIRECTORY,
|
||||||
|
B_COMMON_DATA_DIRECTORY,
|
||||||
|
|
||||||
|
|
||||||
/* ---
|
// User directories. These are interpreted in the context
|
||||||
User directories. These are interpreted in the context
|
// of the user making the find_directory call.
|
||||||
of the user making the find_directory call.
|
|
||||||
--- */
|
|
||||||
|
|
||||||
B_USER_DIRECTORY = 3000,
|
B_USER_DIRECTORY = 3000,
|
||||||
B_USER_CONFIG_DIRECTORY,
|
B_USER_CONFIG_DIRECTORY,
|
||||||
B_USER_ADDONS_DIRECTORY,
|
B_USER_ADDONS_DIRECTORY,
|
||||||
@ -92,46 +69,36 @@ typedef enum {
|
|||||||
B_USER_TRANSLATORS_DIRECTORY,
|
B_USER_TRANSLATORS_DIRECTORY,
|
||||||
B_USER_MEDIA_NODES_DIRECTORY,
|
B_USER_MEDIA_NODES_DIRECTORY,
|
||||||
B_USER_SOUNDS_DIRECTORY,
|
B_USER_SOUNDS_DIRECTORY,
|
||||||
|
B_USER_DATA_DIRECTORY,
|
||||||
|
B_USER_CACHE_DIRECTORY,
|
||||||
|
|
||||||
/* ---
|
// Global directories.
|
||||||
Global directories.
|
|
||||||
--- */
|
|
||||||
|
|
||||||
B_APPS_DIRECTORY = 4000,
|
B_APPS_DIRECTORY = 4000,
|
||||||
B_PREFERENCES_DIRECTORY,
|
B_PREFERENCES_DIRECTORY,
|
||||||
B_UTILITIES_DIRECTORY
|
B_UTILITIES_DIRECTORY
|
||||||
|
|
||||||
} directory_which;
|
} directory_which;
|
||||||
|
|
||||||
/* ---
|
#ifdef __cplusplus
|
||||||
The C interface
|
extern "C" {
|
||||||
--- */
|
#endif
|
||||||
|
|
||||||
|
// C interface
|
||||||
|
|
||||||
status_t find_directory(directory_which which, dev_t volume, bool createIt,
|
status_t find_directory(directory_which which, dev_t volume, bool createIt,
|
||||||
char* pathString, int32 length);
|
char* pathString, int32 length);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
// C++ interface
|
||||||
|
|
||||||
class BVolume;
|
class BVolume;
|
||||||
class BPath;
|
class BPath;
|
||||||
|
|
||||||
/* ---
|
|
||||||
C++ interface
|
|
||||||
--- */
|
|
||||||
|
|
||||||
status_t find_directory(directory_which which, BPath* path,
|
status_t find_directory(directory_which which, BPath* path,
|
||||||
bool createIt = false, BVolume* volume = NULL);
|
bool createIt = false, BVolume* volume = NULL);
|
||||||
|
|
||||||
#endif
|
#endif // __cplusplus
|
||||||
|
|
||||||
#ifdef USE_OPENBEOS_NAMESPACE
|
|
||||||
}; // namespace OpenBeOS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // _FIND_DIRECTORY_H
|
#endif // _FIND_DIRECTORY_H
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2004-2007, François Revol.
|
* Copyright (c) 2004-2008, François Revol.
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -31,26 +31,27 @@
|
|||||||
/* Haiku system directories */
|
/* Haiku system directories */
|
||||||
|
|
||||||
/* os root dir; just stick to 'beos' for now */
|
/* os root dir; just stick to 'beos' for now */
|
||||||
#define OS "beos"
|
#define SYSTEM "beos"
|
||||||
//#define OS "haiku" // :)
|
//#define SYSTEM "haiku" // :)
|
||||||
//#define OS "os"
|
//#define SYSTEM "os"
|
||||||
|
|
||||||
static const char *os_dirs[] = {
|
static const char *kSystemDirectories[] = {
|
||||||
OS, // B_BEOS_DIRECTORY
|
SYSTEM, // B_BEOS_DIRECTORY
|
||||||
OS "/system",
|
SYSTEM "/system",
|
||||||
OS "/system/add-ons",
|
SYSTEM "/system/add-ons",
|
||||||
OS "/system/boot",
|
SYSTEM "/system/boot",
|
||||||
OS "/etc/fonts",
|
SYSTEM "/etc/fonts",
|
||||||
OS "/system/lib",
|
SYSTEM "/system/lib",
|
||||||
OS "/system/servers",
|
SYSTEM "/system/servers",
|
||||||
OS "/apps",
|
SYSTEM "/apps",
|
||||||
OS "/bin",
|
SYSTEM "/bin",
|
||||||
OS "/etc",
|
SYSTEM "/etc",
|
||||||
OS "/documentation",
|
SYSTEM "/documentation",
|
||||||
OS "/preferences",
|
SYSTEM "/preferences",
|
||||||
OS "/system/add-ons/Translators",
|
SYSTEM "/system/add-ons/Translators",
|
||||||
OS "/system/add-ons/media",
|
SYSTEM "/system/add-ons/media",
|
||||||
OS "/etc/sounds",
|
SYSTEM "/etc/sounds",
|
||||||
|
SYSTEM "/etc",
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Common directories, shared among users */
|
/* Common directories, shared among users */
|
||||||
@ -59,7 +60,7 @@ static const char *os_dirs[] = {
|
|||||||
// ToDo: this is for now and might be changed back to "home"
|
// ToDo: this is for now and might be changed back to "home"
|
||||||
// (or even something else) later
|
// (or even something else) later
|
||||||
|
|
||||||
static const char *common_dirs[] = {
|
static const char *kCommonDirectories[] = {
|
||||||
COMMON "", // B_COMMON_DIRECTORY
|
COMMON "", // B_COMMON_DIRECTORY
|
||||||
COMMON "", // B_COMMON_SYSTEM_DIRECTORY
|
COMMON "", // B_COMMON_SYSTEM_DIRECTORY
|
||||||
COMMON "/add-ons",
|
COMMON "/add-ons",
|
||||||
@ -79,13 +80,14 @@ static const char *common_dirs[] = {
|
|||||||
COMMON "/add-ons/Translators",
|
COMMON "/add-ons/Translators",
|
||||||
COMMON "/add-ons/media",
|
COMMON "/add-ons/media",
|
||||||
COMMON "/sounds",
|
COMMON "/sounds",
|
||||||
|
COMMON "/data",
|
||||||
};
|
};
|
||||||
|
|
||||||
/* User directories */
|
/* User directories */
|
||||||
|
|
||||||
#define HOME "$h"
|
#define HOME "$h"
|
||||||
|
|
||||||
static const char *user_dirs[] = {
|
static const char *kUserDirectories[] = {
|
||||||
HOME "", // B_USER_DIRECTORY
|
HOME "", // B_USER_DIRECTORY
|
||||||
HOME "/config", // B_USER_CONFIG_DIRECTORY
|
HOME "/config", // B_USER_CONFIG_DIRECTORY
|
||||||
HOME "/config/add-ons",
|
HOME "/config/add-ons",
|
||||||
@ -98,6 +100,8 @@ static const char *user_dirs[] = {
|
|||||||
HOME "/config/add-ons/Translators",
|
HOME "/config/add-ons/Translators",
|
||||||
HOME "/config/add-ons/media",
|
HOME "/config/add-ons/media",
|
||||||
HOME "/config/sounds",
|
HOME "/config/sounds",
|
||||||
|
HOME "/config/data",
|
||||||
|
HOME "/config/cache",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -219,7 +223,8 @@ find_directory(directory_which which, dev_t device, bool createIt,
|
|||||||
case B_BEOS_TRANSLATORS_DIRECTORY:
|
case B_BEOS_TRANSLATORS_DIRECTORY:
|
||||||
case B_BEOS_MEDIA_NODES_DIRECTORY:
|
case B_BEOS_MEDIA_NODES_DIRECTORY:
|
||||||
case B_BEOS_SOUNDS_DIRECTORY:
|
case B_BEOS_SOUNDS_DIRECTORY:
|
||||||
template = os_dirs[which - B_BEOS_DIRECTORY];
|
case B_BEOS_DATA_DIRECTORY:
|
||||||
|
template = kSystemDirectories[which - B_BEOS_DIRECTORY];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Common directories, shared among users */
|
/* Common directories, shared among users */
|
||||||
@ -242,7 +247,8 @@ find_directory(directory_which which, dev_t device, bool createIt,
|
|||||||
case B_COMMON_TRANSLATORS_DIRECTORY:
|
case B_COMMON_TRANSLATORS_DIRECTORY:
|
||||||
case B_COMMON_MEDIA_NODES_DIRECTORY:
|
case B_COMMON_MEDIA_NODES_DIRECTORY:
|
||||||
case B_COMMON_SOUNDS_DIRECTORY:
|
case B_COMMON_SOUNDS_DIRECTORY:
|
||||||
template = common_dirs[which - B_COMMON_DIRECTORY];
|
case B_COMMON_DATA_DIRECTORY:
|
||||||
|
template = kCommonDirectories[which - B_COMMON_DIRECTORY];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* User directories */
|
/* User directories */
|
||||||
@ -258,7 +264,9 @@ find_directory(directory_which which, dev_t device, bool createIt,
|
|||||||
case B_USER_TRANSLATORS_DIRECTORY:
|
case B_USER_TRANSLATORS_DIRECTORY:
|
||||||
case B_USER_MEDIA_NODES_DIRECTORY:
|
case B_USER_MEDIA_NODES_DIRECTORY:
|
||||||
case B_USER_SOUNDS_DIRECTORY:
|
case B_USER_SOUNDS_DIRECTORY:
|
||||||
template = user_dirs[which - B_USER_DIRECTORY];
|
case B_USER_DATA_DIRECTORY:
|
||||||
|
case B_USER_CACHE_DIRECTORY:
|
||||||
|
template = kUserDirectories[which - B_USER_DIRECTORY];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Global directories */
|
/* Global directories */
|
||||||
|
Loading…
Reference in New Issue
Block a user