* 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
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file FindDirectory.h
|
||||
Declarations of find_directory() functions and associated types.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2002-2008, Haiku Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _FIND_DIRECTORY_H
|
||||
#define _FIND_DIRECTORY_H
|
||||
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
namespace OpenBeOS {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
/* ---
|
||||
Per volume directories. When asking for these
|
||||
directories, a volume must be specified, or the call will assume
|
||||
the boot volume.
|
||||
--- */
|
||||
|
||||
// Per volume directories
|
||||
B_DESKTOP_DIRECTORY = 0,
|
||||
B_TRASH_DIRECTORY,
|
||||
|
||||
/* ---
|
||||
BeOS directories. These are mostly accessed read-only.
|
||||
--- */
|
||||
|
||||
// System directories
|
||||
B_BEOS_DIRECTORY = 1000,
|
||||
B_BEOS_SYSTEM_DIRECTORY,
|
||||
B_BEOS_ADDONS_DIRECTORY,
|
||||
@ -49,11 +30,9 @@ typedef enum {
|
||||
B_BEOS_TRANSLATORS_DIRECTORY,
|
||||
B_BEOS_MEDIA_NODES_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_SYSTEM_DIRECTORY,
|
||||
B_COMMON_ADDONS_DIRECTORY,
|
||||
@ -73,13 +52,11 @@ typedef enum {
|
||||
B_COMMON_TRANSLATORS_DIRECTORY,
|
||||
B_COMMON_MEDIA_NODES_DIRECTORY,
|
||||
B_COMMON_SOUNDS_DIRECTORY,
|
||||
B_COMMON_DATA_DIRECTORY,
|
||||
|
||||
|
||||
/* ---
|
||||
User directories. These are interpreted in the context
|
||||
of the user making the find_directory call.
|
||||
--- */
|
||||
|
||||
// User directories. These are interpreted in the context
|
||||
// of the user making the find_directory call.
|
||||
B_USER_DIRECTORY = 3000,
|
||||
B_USER_CONFIG_DIRECTORY,
|
||||
B_USER_ADDONS_DIRECTORY,
|
||||
@ -92,46 +69,36 @@ typedef enum {
|
||||
B_USER_TRANSLATORS_DIRECTORY,
|
||||
B_USER_MEDIA_NODES_DIRECTORY,
|
||||
B_USER_SOUNDS_DIRECTORY,
|
||||
B_USER_DATA_DIRECTORY,
|
||||
B_USER_CACHE_DIRECTORY,
|
||||
|
||||
/* ---
|
||||
Global directories.
|
||||
--- */
|
||||
|
||||
// Global directories.
|
||||
B_APPS_DIRECTORY = 4000,
|
||||
B_PREFERENCES_DIRECTORY,
|
||||
B_UTILITIES_DIRECTORY
|
||||
|
||||
} directory_which;
|
||||
|
||||
/* ---
|
||||
The C interface
|
||||
--- */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// C interface
|
||||
|
||||
status_t find_directory(directory_which which, dev_t volume, bool createIt,
|
||||
char *pathString, int32 length);
|
||||
char* pathString, int32 length);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
// C++ interface
|
||||
|
||||
class BVolume;
|
||||
class BPath;
|
||||
|
||||
/* ---
|
||||
C++ interface
|
||||
--- */
|
||||
status_t find_directory(directory_which which, BPath* path,
|
||||
bool createIt = false, BVolume* volume = NULL);
|
||||
|
||||
status_t find_directory(directory_which which, BPath *path,
|
||||
bool createIt = false, BVolume *volume = NULL);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
}; // namespace OpenBeOS
|
||||
#endif
|
||||
#endif // __cplusplus
|
||||
|
||||
#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.
|
||||
*/
|
||||
|
||||
@ -31,26 +31,27 @@
|
||||
/* Haiku system directories */
|
||||
|
||||
/* os root dir; just stick to 'beos' for now */
|
||||
#define OS "beos"
|
||||
//#define OS "haiku" // :)
|
||||
//#define OS "os"
|
||||
#define SYSTEM "beos"
|
||||
//#define SYSTEM "haiku" // :)
|
||||
//#define SYSTEM "os"
|
||||
|
||||
static const char *os_dirs[] = {
|
||||
OS, // B_BEOS_DIRECTORY
|
||||
OS "/system",
|
||||
OS "/system/add-ons",
|
||||
OS "/system/boot",
|
||||
OS "/etc/fonts",
|
||||
OS "/system/lib",
|
||||
OS "/system/servers",
|
||||
OS "/apps",
|
||||
OS "/bin",
|
||||
OS "/etc",
|
||||
OS "/documentation",
|
||||
OS "/preferences",
|
||||
OS "/system/add-ons/Translators",
|
||||
OS "/system/add-ons/media",
|
||||
OS "/etc/sounds",
|
||||
static const char *kSystemDirectories[] = {
|
||||
SYSTEM, // B_BEOS_DIRECTORY
|
||||
SYSTEM "/system",
|
||||
SYSTEM "/system/add-ons",
|
||||
SYSTEM "/system/boot",
|
||||
SYSTEM "/etc/fonts",
|
||||
SYSTEM "/system/lib",
|
||||
SYSTEM "/system/servers",
|
||||
SYSTEM "/apps",
|
||||
SYSTEM "/bin",
|
||||
SYSTEM "/etc",
|
||||
SYSTEM "/documentation",
|
||||
SYSTEM "/preferences",
|
||||
SYSTEM "/system/add-ons/Translators",
|
||||
SYSTEM "/system/add-ons/media",
|
||||
SYSTEM "/etc/sounds",
|
||||
SYSTEM "/etc",
|
||||
};
|
||||
|
||||
/* 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"
|
||||
// (or even something else) later
|
||||
|
||||
static const char *common_dirs[] = {
|
||||
static const char *kCommonDirectories[] = {
|
||||
COMMON "", // B_COMMON_DIRECTORY
|
||||
COMMON "", // B_COMMON_SYSTEM_DIRECTORY
|
||||
COMMON "/add-ons",
|
||||
@ -79,13 +80,14 @@ static const char *common_dirs[] = {
|
||||
COMMON "/add-ons/Translators",
|
||||
COMMON "/add-ons/media",
|
||||
COMMON "/sounds",
|
||||
COMMON "/data",
|
||||
};
|
||||
|
||||
/* User directories */
|
||||
|
||||
#define HOME "$h"
|
||||
|
||||
static const char *user_dirs[] = {
|
||||
static const char *kUserDirectories[] = {
|
||||
HOME "", // B_USER_DIRECTORY
|
||||
HOME "/config", // B_USER_CONFIG_DIRECTORY
|
||||
HOME "/config/add-ons",
|
||||
@ -98,6 +100,8 @@ static const char *user_dirs[] = {
|
||||
HOME "/config/add-ons/Translators",
|
||||
HOME "/config/add-ons/media",
|
||||
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_MEDIA_NODES_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;
|
||||
|
||||
/* 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_MEDIA_NODES_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;
|
||||
|
||||
/* User directories */
|
||||
@ -258,7 +264,9 @@ find_directory(directory_which which, dev_t device, bool createIt,
|
||||
case B_USER_TRANSLATORS_DIRECTORY:
|
||||
case B_USER_MEDIA_NODES_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;
|
||||
|
||||
/* Global directories */
|
||||
@ -276,7 +284,7 @@ find_directory(directory_which which, dev_t device, bool createIt,
|
||||
free(buffer);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
|
||||
err = B_OK;
|
||||
if (template) {
|
||||
if (!strncmp(template, "$h", 2)) {
|
||||
|
Loading…
Reference in New Issue
Block a user