It is accomplished ...
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file Directory.h
|
||||
BDirectory interface declaration.
|
||||
*/
|
||||
|
||||
#ifndef __sk_directory_h__
|
||||
#define __sk_directory_h__
|
||||
|
||||
#include <Node.h>
|
||||
#include <EntryList.h>
|
||||
#include <StorageDefs.h>
|
||||
#include <StorageDefs.Private.h>
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
namespace OpenBeOS {
|
||||
#endif
|
||||
|
||||
class BSymLink;
|
||||
|
||||
/*!
|
||||
\class BDirectory
|
||||
\brief A directory in the filesystem
|
||||
|
||||
Provides an interface for manipulating directories and their contents.
|
||||
|
||||
\author <a href='mailto:[email protected]'>Ingo Weinhold</a>
|
||||
\author <a href="mailto:[email protected]">Tyler Dauwalder</a>
|
||||
|
||||
\version 0.0.0
|
||||
*/
|
||||
class BDirectory : public BNode, public BEntryList {
|
||||
public:
|
||||
BDirectory();
|
||||
BDirectory(const BDirectory &dir);
|
||||
BDirectory(const entry_ref *ref);
|
||||
BDirectory(const node_ref *nref);
|
||||
BDirectory(const BEntry *entry);
|
||||
BDirectory(const char *path);
|
||||
BDirectory(const BDirectory *dir, const char *path);
|
||||
|
||||
virtual ~BDirectory();
|
||||
|
||||
status_t SetTo(const entry_ref *ref);
|
||||
status_t SetTo(const node_ref *nref);
|
||||
status_t SetTo(const BEntry *entry);
|
||||
status_t SetTo(const char *path);
|
||||
status_t SetTo(const BDirectory *dir, const char *path);
|
||||
|
||||
status_t GetEntry(BEntry *entry) const;
|
||||
|
||||
bool IsRootDirectory() const;
|
||||
|
||||
status_t FindEntry(const char *path, BEntry *entry,
|
||||
bool traverse = false) const;
|
||||
|
||||
bool Contains(const char *path, int32 nodeFlags = B_ANY_NODE) const;
|
||||
bool Contains(const BEntry *entry, int32 nodeFlags = B_ANY_NODE) const;
|
||||
|
||||
status_t GetStatFor(const char *path, struct stat *st) const;
|
||||
|
||||
virtual status_t GetNextEntry(BEntry *entry, bool traverse = false);
|
||||
virtual status_t GetNextRef(entry_ref *ref);
|
||||
virtual int32 GetNextDirents(dirent *buf, size_t bufSize,
|
||||
int32 count = INT_MAX);
|
||||
virtual status_t Rewind();
|
||||
virtual int32 CountEntries();
|
||||
|
||||
status_t CreateDirectory(const char *path, BDirectory *dir);
|
||||
status_t CreateFile(const char *path, BFile *file,
|
||||
bool failIfExists = false);
|
||||
status_t CreateSymLink(const char *path, const char *linkToPath,
|
||||
BSymLink *link);
|
||||
|
||||
BDirectory &operator=(const BDirectory &dir);
|
||||
|
||||
private:
|
||||
virtual void _ReservedDirectory1();
|
||||
virtual void _ReservedDirectory2();
|
||||
virtual void _ReservedDirectory3();
|
||||
virtual void _ReservedDirectory4();
|
||||
virtual void _ReservedDirectory5();
|
||||
virtual void _ReservedDirectory6();
|
||||
|
||||
private:
|
||||
virtual void close_fd();
|
||||
StorageKit::FileDescriptor get_fd() const;
|
||||
|
||||
private:
|
||||
uint32 _reservedData[7];
|
||||
StorageKit::FileDescriptor fDirFd;
|
||||
|
||||
friend class BEntry;
|
||||
};
|
||||
|
||||
|
||||
// C functions
|
||||
|
||||
status_t create_directory(const char *path, mode_t mode);
|
||||
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
}; // namespace OpenBeOS
|
||||
#endif
|
||||
|
||||
#endif // __sk_directory_h__
|
||||
@@ -0,0 +1,120 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file Entry.h
|
||||
BEntry and entry_ref interface declarations.
|
||||
*/
|
||||
#ifndef __sk_entry_h__
|
||||
#define __sk_entry_h__
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <SupportDefs.h>
|
||||
|
||||
#include <Statable.h>
|
||||
#include <StorageDefs.Private.h>
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
namespace OpenBeOS {
|
||||
#endif
|
||||
|
||||
class BDirectory;
|
||||
class BPath;
|
||||
|
||||
struct entry_ref {
|
||||
entry_ref();
|
||||
entry_ref(dev_t dev, ino_t dir, const char *name);
|
||||
entry_ref(const entry_ref &ref);
|
||||
~entry_ref();
|
||||
|
||||
status_t set_name(const char *name);
|
||||
|
||||
bool operator==(const entry_ref &ref) const;
|
||||
bool operator!=(const entry_ref &ref) const;
|
||||
entry_ref &operator=(const entry_ref &ref);
|
||||
|
||||
dev_t device;
|
||||
ino_t directory;
|
||||
char *name;
|
||||
};
|
||||
|
||||
class BEntry : public BStatable {
|
||||
public:
|
||||
BEntry();
|
||||
BEntry(const BDirectory *dir, const char *path, bool traverse = false);
|
||||
BEntry(const entry_ref *ref, bool traverse = false);
|
||||
BEntry(const char *path, bool traverse = false);
|
||||
BEntry(const BEntry &entry);
|
||||
virtual ~BEntry();
|
||||
|
||||
status_t InitCheck() const;
|
||||
bool Exists() const;
|
||||
|
||||
virtual status_t GetStat(struct stat *st) const;
|
||||
|
||||
status_t SetTo(const BDirectory *dir, const char *path,
|
||||
bool traverse = false);
|
||||
status_t SetTo(const entry_ref *ref, bool traverse = false);
|
||||
status_t SetTo(const char *path, bool traverse = false);
|
||||
void Unset();
|
||||
|
||||
status_t GetRef(entry_ref *ref) const;
|
||||
status_t GetPath(BPath *path) const;
|
||||
status_t GetParent(BEntry *entry) const;
|
||||
status_t GetParent(BDirectory *dir) const;
|
||||
status_t GetName(char *buffer) const;
|
||||
|
||||
status_t Rename(const char *path, bool clobber = false);
|
||||
status_t MoveTo(BDirectory *dir, const char *path = NULL,
|
||||
bool clobber = false);
|
||||
status_t Remove();
|
||||
|
||||
bool operator==(const BEntry &item) const;
|
||||
bool operator!=(const BEntry &item) const;
|
||||
|
||||
BEntry &operator=(const BEntry &item);
|
||||
|
||||
private:
|
||||
virtual void _PennyEntry1();
|
||||
virtual void _PennyEntry2();
|
||||
virtual void _PennyEntry3();
|
||||
virtual void _PennyEntry4();
|
||||
virtual void _PennyEntry5();
|
||||
virtual void _PennyEntry6();
|
||||
|
||||
/*! Currently unused. */
|
||||
uint32 _pennyData[4];
|
||||
|
||||
/*! BEntry implementation of BStatable::set_stat() */
|
||||
virtual status_t set_stat(struct stat &st, uint32 what);
|
||||
|
||||
status_t set(StorageKit::FileDescriptor dir, const char *path,
|
||||
bool traverse);
|
||||
|
||||
/*! File descriptor for the entry's parent directory. */
|
||||
StorageKit::FileDescriptor fDirFd;
|
||||
|
||||
/*! Leaf name of the entry. */
|
||||
char *fName;
|
||||
|
||||
/*! The object's initialization status. */
|
||||
status_t fCStatus;
|
||||
|
||||
status_t set_name(const char *name);
|
||||
|
||||
void Dump(const char *name = NULL);
|
||||
};
|
||||
|
||||
// C functions
|
||||
|
||||
status_t get_ref_for_path(const char *path, entry_ref *ref);
|
||||
bool operator<(const entry_ref &a, const entry_ref &b);
|
||||
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
}; // namespace OpenBeOS
|
||||
#endif
|
||||
|
||||
#endif // __sk_entry_h__
|
||||
@@ -0,0 +1,60 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file EntryList.h
|
||||
BEntryList interface declaration.
|
||||
*/
|
||||
|
||||
#ifndef __sk_entry_list_h__
|
||||
#define __sk_entry_list_h__
|
||||
|
||||
#include <dirent.h>
|
||||
#include <SupportDefs.h>
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
namespace OpenBeOS {
|
||||
#endif
|
||||
|
||||
// Forward declarations
|
||||
class BEntry;
|
||||
struct entry_ref;
|
||||
|
||||
//! Interface for iterating through a list of filesystem entries
|
||||
/*! Defines a general interface for iterating through a list of entries (i.e.
|
||||
files in a folder
|
||||
|
||||
@author <a href='mailto:[email protected]'>Tyler Dauwalder</a>
|
||||
@author Be Inc.
|
||||
@version 0.0.0
|
||||
*/
|
||||
class BEntryList {
|
||||
public:
|
||||
BEntryList();
|
||||
virtual ~BEntryList();
|
||||
|
||||
virtual status_t GetNextEntry(BEntry *entry, bool traverse = false) = 0;
|
||||
virtual status_t GetNextRef(entry_ref *ref) = 0;
|
||||
virtual int32 GetNextDirents(struct dirent *buf, size_t length,
|
||||
int32 count = INT_MAX) = 0;
|
||||
virtual status_t Rewind() = 0;
|
||||
virtual int32 CountEntries() = 0;
|
||||
|
||||
private:
|
||||
virtual void _ReservedEntryList1();
|
||||
virtual void _ReservedEntryList2();
|
||||
virtual void _ReservedEntryList3();
|
||||
virtual void _ReservedEntryList4();
|
||||
virtual void _ReservedEntryList5();
|
||||
virtual void _ReservedEntryList6();
|
||||
virtual void _ReservedEntryList7();
|
||||
virtual void _ReservedEntryList8();
|
||||
|
||||
};
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
}; // namespace OpenBeOS
|
||||
#endif
|
||||
|
||||
#endif // __sk_entry_list_h__
|
||||
@@ -0,0 +1,85 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file File.h
|
||||
BFile interface declaration.
|
||||
*/
|
||||
#ifndef __sk_file_h__
|
||||
#define __sk_file_h__
|
||||
|
||||
#include <DataIO.h>
|
||||
#include <Node.h>
|
||||
#include <StorageDefs.Private.h>
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
namespace OpenBeOS {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
\class BFile
|
||||
\brief BFile is a wrapper class for common operations on files providing
|
||||
access to the file's content data and its attributes.
|
||||
|
||||
A BFile represents a file in some file system. It implements the
|
||||
BPositionIO interface and thus the methods to read from and write to the
|
||||
file, and is derived of BNode to provide access to the file's attributes.
|
||||
|
||||
\author <a href='mailto:[email protected]'>Ingo Weinhold</a>
|
||||
|
||||
\version 0.0.0
|
||||
*/
|
||||
class BFile : public BNode, public BPositionIO {
|
||||
public:
|
||||
BFile();
|
||||
BFile(const BFile &file);
|
||||
BFile(const entry_ref *ref, uint32 openMode);
|
||||
BFile(const BEntry *entry, uint32 openMode);
|
||||
BFile(const char *path, uint32 openMode);
|
||||
BFile(BDirectory *dir, const char *path, uint32 openMode);
|
||||
virtual ~BFile();
|
||||
|
||||
status_t SetTo(const entry_ref *ref, uint32 openMode);
|
||||
status_t SetTo(const BEntry *entry, uint32 openMode);
|
||||
status_t SetTo(const char *path, uint32 openMode);
|
||||
status_t SetTo(const BDirectory *dir, const char *path, uint32 openMode);
|
||||
|
||||
bool IsReadable() const;
|
||||
bool IsWritable() const;
|
||||
|
||||
virtual ssize_t Read(void *buffer, size_t size);
|
||||
virtual ssize_t ReadAt(off_t location, void *buffer, size_t size);
|
||||
virtual ssize_t Write(const void *buffer, size_t size);
|
||||
virtual ssize_t WriteAt(off_t location, const void *buffer, size_t size);
|
||||
|
||||
virtual off_t Seek(off_t offset, uint32 seekMode);
|
||||
virtual off_t Position() const;
|
||||
|
||||
virtual status_t SetSize(off_t size);
|
||||
|
||||
BFile &operator=(const BFile &file);
|
||||
|
||||
private:
|
||||
virtual void _ReservedFile1();
|
||||
virtual void _ReservedFile2();
|
||||
virtual void _ReservedFile3();
|
||||
virtual void _ReservedFile4();
|
||||
virtual void _ReservedFile5();
|
||||
virtual void _ReservedFile6();
|
||||
|
||||
uint32 _reservedData[8];
|
||||
|
||||
private:
|
||||
StorageKit::FileDescriptor get_fd() const;
|
||||
|
||||
private:
|
||||
//! The file's open mode.
|
||||
uint32 fMode;
|
||||
};
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
}; // namespace OpenBeOS
|
||||
#endif
|
||||
|
||||
#endif // __sk_file_h__
|
||||
@@ -0,0 +1,135 @@
|
||||
//----------------------------------------------------------------------
|
||||
// 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.
|
||||
*/
|
||||
|
||||
#ifndef __sk_find_directory_h__
|
||||
#define __sk_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.
|
||||
--- */
|
||||
|
||||
B_DESKTOP_DIRECTORY = 0,
|
||||
B_TRASH_DIRECTORY,
|
||||
|
||||
/* ---
|
||||
BeOS directories. These are mostly accessed read-only.
|
||||
--- */
|
||||
|
||||
B_BEOS_DIRECTORY = 1000,
|
||||
B_BEOS_SYSTEM_DIRECTORY,
|
||||
B_BEOS_ADDONS_DIRECTORY,
|
||||
B_BEOS_BOOT_DIRECTORY,
|
||||
B_BEOS_FONTS_DIRECTORY,
|
||||
B_BEOS_LIB_DIRECTORY,
|
||||
B_BEOS_SERVERS_DIRECTORY,
|
||||
B_BEOS_APPS_DIRECTORY,
|
||||
B_BEOS_BIN_DIRECTORY,
|
||||
B_BEOS_ETC_DIRECTORY,
|
||||
B_BEOS_DOCUMENTATION_DIRECTORY,
|
||||
B_BEOS_PREFERENCES_DIRECTORY,
|
||||
B_BEOS_TRANSLATORS_DIRECTORY,
|
||||
B_BEOS_MEDIA_NODES_DIRECTORY,
|
||||
B_BEOS_SOUNDS_DIRECTORY,
|
||||
|
||||
/* ---
|
||||
Common directories, shared among all users.
|
||||
--- */
|
||||
|
||||
B_COMMON_DIRECTORY = 2000,
|
||||
B_COMMON_SYSTEM_DIRECTORY,
|
||||
B_COMMON_ADDONS_DIRECTORY,
|
||||
B_COMMON_BOOT_DIRECTORY,
|
||||
B_COMMON_FONTS_DIRECTORY,
|
||||
B_COMMON_LIB_DIRECTORY,
|
||||
B_COMMON_SERVERS_DIRECTORY,
|
||||
B_COMMON_BIN_DIRECTORY,
|
||||
B_COMMON_ETC_DIRECTORY,
|
||||
B_COMMON_DOCUMENTATION_DIRECTORY,
|
||||
B_COMMON_SETTINGS_DIRECTORY,
|
||||
B_COMMON_DEVELOP_DIRECTORY,
|
||||
B_COMMON_LOG_DIRECTORY,
|
||||
B_COMMON_SPOOL_DIRECTORY,
|
||||
B_COMMON_TEMP_DIRECTORY,
|
||||
B_COMMON_VAR_DIRECTORY,
|
||||
B_COMMON_TRANSLATORS_DIRECTORY,
|
||||
B_COMMON_MEDIA_NODES_DIRECTORY,
|
||||
B_COMMON_SOUNDS_DIRECTORY,
|
||||
|
||||
|
||||
/* ---
|
||||
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,
|
||||
B_USER_BOOT_DIRECTORY,
|
||||
B_USER_FONTS_DIRECTORY,
|
||||
B_USER_LIB_DIRECTORY,
|
||||
B_USER_SETTINGS_DIRECTORY,
|
||||
B_USER_DESKBAR_DIRECTORY,
|
||||
B_USER_PRINTERS_DIRECTORY,
|
||||
B_USER_TRANSLATORS_DIRECTORY,
|
||||
B_USER_MEDIA_NODES_DIRECTORY,
|
||||
B_USER_SOUNDS_DIRECTORY,
|
||||
|
||||
/* ---
|
||||
Global directories.
|
||||
--- */
|
||||
|
||||
B_APPS_DIRECTORY = 4000,
|
||||
B_PREFERENCES_DIRECTORY,
|
||||
B_UTILITIES_DIRECTORY
|
||||
|
||||
} directory_which;
|
||||
|
||||
/* ---
|
||||
The C interface
|
||||
--- */
|
||||
|
||||
status_t find_directory(directory_which which, dev_t volume, bool createIt,
|
||||
char *pathString, int32 length);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
class BVolume;
|
||||
class BPath;
|
||||
|
||||
/* ---
|
||||
C++ interface
|
||||
--- */
|
||||
|
||||
status_t find_directory(directory_which which, BPath *path,
|
||||
bool createIt = false, BVolume *volume = NULL);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
}; // namespace OpenBeOS
|
||||
#endif
|
||||
|
||||
#endif // __sk_find_directory_h__
|
||||
@@ -0,0 +1,45 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file Mime.h
|
||||
Mime type C functions interface declarations.
|
||||
*/
|
||||
#ifndef _sk_mime_h_
|
||||
#define _sk_mime_h_
|
||||
|
||||
#include <SupportDefs.h>
|
||||
#include <StorageDefs.h>
|
||||
|
||||
// C functions
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int update_mime_info(const char *path, int recursive, int synchronous,
|
||||
int force);
|
||||
|
||||
status_t create_app_meta_mime(const char *path, int recursive, int synchronous,
|
||||
int force);
|
||||
|
||||
status_t get_device_icon(const char *dev, void *icon, int32 size);
|
||||
|
||||
static const uint32 B_MIME_STRING_TYPE = 'MIMS';
|
||||
|
||||
enum icon_size {
|
||||
B_LARGE_ICON = 32,
|
||||
B_MINI_ICON = 16
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
// include the C++ API
|
||||
#ifdef __cplusplus
|
||||
#include <MimeType.h>
|
||||
#endif
|
||||
|
||||
#endif // _sk_mime_h_
|
||||
@@ -0,0 +1,192 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file MimeType.h
|
||||
BMimeType interface declarations.
|
||||
*/
|
||||
#ifndef _sk_mime_type_h_
|
||||
#define _sk_mime_type_h_
|
||||
|
||||
#include <SupportDefs.h>
|
||||
#include <StorageDefs.h>
|
||||
|
||||
#include <Messenger.h>
|
||||
#include <Mime.h>
|
||||
#include <File.h>
|
||||
#include <Entry.h>
|
||||
|
||||
class BBitmap;
|
||||
class BResources;
|
||||
class BAppFileInfo;
|
||||
class BMessenger;
|
||||
|
||||
enum app_verb {
|
||||
B_OPEN
|
||||
};
|
||||
|
||||
extern const char *B_APP_MIME_TYPE; // platform dependent
|
||||
extern const char *B_PEF_APP_MIME_TYPE; // "application/x-be-executable"
|
||||
extern const char *B_PE_APP_MIME_TYPE; // "application/x-vnd.be-peexecutable"
|
||||
extern const char *B_ELF_APP_MIME_TYPE; // "application/x-vnd.be-elfexecutable"
|
||||
extern const char *B_RESOURCE_MIME_TYPE;// "application/x-be-resource"
|
||||
extern const char *B_FILE_MIME_TYPE; // "application/octet-stream"
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
|
||||
enum {
|
||||
B_META_MIME_CHANGED = 'MMCH'
|
||||
};
|
||||
|
||||
enum {
|
||||
B_ICON_CHANGED = 0x00000001,
|
||||
B_PREFERRED_APP_CHANGED = 0x00000002,
|
||||
B_ATTR_INFO_CHANGED = 0x00000004,
|
||||
B_FILE_EXTENSIONS_CHANGED = 0x00000008,
|
||||
B_SHORT_DESCRIPTION_CHANGED = 0x00000010,
|
||||
B_LONG_DESCRIPTION_CHANGED = 0x00000020,
|
||||
B_ICON_FOR_TYPE_CHANGED = 0x00000040,
|
||||
B_APP_HINT_CHANGED = 0x00000080,
|
||||
B_MIME_TYPE_CREATED = 0x00000100,
|
||||
B_MIME_TYPE_DELETED = 0x00000200,
|
||||
B_SNIFFER_RULE_CHANGED = 0x00000400,
|
||||
|
||||
B_EVERYTHING_CHANGED = (int)0xFFFFFFFF
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
|
||||
//! File typing functionality.
|
||||
/*! The BMimeType class provides access to the file typing system, which
|
||||
provides the following functionality:
|
||||
- Basic MIME string manipulation
|
||||
- Access to file type information in the MIME database
|
||||
- Ways to receive notifications when parts of the MIME database are updated
|
||||
- Methods to determine/help determine the types of untyped files
|
||||
|
||||
\author <a href='mailto:[email protected]'>Tyler Dauwalder</a>
|
||||
\author <a href='[email protected]'>Ingo Weinhold</a>
|
||||
\version 0.0.0
|
||||
*/
|
||||
class BMimeType {
|
||||
public:
|
||||
BMimeType();
|
||||
BMimeType(const char *mimeType);
|
||||
virtual ~BMimeType();
|
||||
|
||||
status_t SetTo(const char *mimeType);
|
||||
void Unset();
|
||||
status_t InitCheck() const;
|
||||
|
||||
/* these functions simply perform string manipulations*/
|
||||
const char *Type() const;
|
||||
bool IsValid() const;
|
||||
bool IsSupertypeOnly() const;
|
||||
bool IsInstalled() const;
|
||||
status_t GetSupertype(BMimeType *superType) const;
|
||||
|
||||
bool operator==(const BMimeType &type) const;
|
||||
bool operator==(const char *type) const;
|
||||
|
||||
bool Contains(const BMimeType *type) const;
|
||||
|
||||
/* These functions are for managing data in the meta mime file*/
|
||||
status_t Install();
|
||||
status_t Delete();
|
||||
status_t GetIcon(BBitmap *icon, icon_size size) const;
|
||||
status_t GetPreferredApp(char *signature, app_verb verb = B_OPEN) const;
|
||||
status_t GetAttrInfo(BMessage *info) const;
|
||||
status_t GetFileExtensions(BMessage *extensions) const;
|
||||
status_t GetShortDescription(char *description) const;
|
||||
status_t GetLongDescription(char *description) const;
|
||||
status_t GetSupportingApps(BMessage *signatures) const;
|
||||
|
||||
status_t SetIcon(const BBitmap *icon, icon_size size);
|
||||
status_t SetPreferredApp(const char *signature, app_verb verb = B_OPEN);
|
||||
status_t SetAttrInfo(const BMessage *info);
|
||||
status_t SetFileExtensions(const BMessage *extensions);
|
||||
status_t SetShortDescription(const char *description);
|
||||
status_t SetLongDescription(const char *description);
|
||||
|
||||
static status_t GetInstalledSupertypes(BMessage *super_types);
|
||||
static status_t GetInstalledTypes(BMessage *types);
|
||||
static status_t GetInstalledTypes(const char *super_type,
|
||||
BMessage *subtypes);
|
||||
static status_t GetWildcardApps(BMessage *wild_ones);
|
||||
static bool IsValid(const char *mimeType);
|
||||
|
||||
status_t GetAppHint(entry_ref *ref) const;
|
||||
status_t SetAppHint(const entry_ref *ref);
|
||||
|
||||
/* for application signatures only.*/
|
||||
status_t GetIconForType(const char *type, BBitmap *icon,
|
||||
icon_size which) const;
|
||||
status_t SetIconForType(const char *type, const BBitmap *icon,
|
||||
icon_size which);
|
||||
|
||||
/* sniffer rule manipulation */
|
||||
status_t GetSnifferRule(BString *result) const;
|
||||
status_t SetSnifferRule(const char *);
|
||||
static status_t CheckSnifferRule(const char *rule, BString *parseError);
|
||||
|
||||
/* calls to ask the sniffer to identify the MIME type of a file or data in
|
||||
memory */
|
||||
static status_t GuessMimeType(const entry_ref *file, BMimeType *result);
|
||||
static status_t GuessMimeType(const void *buffer, int32 length,
|
||||
BMimeType *result);
|
||||
static status_t GuessMimeType(const char *filename, BMimeType *result);
|
||||
|
||||
static status_t StartWatching(BMessenger target);
|
||||
static status_t StopWatching(BMessenger target);
|
||||
|
||||
/* Deprecated Use SetTo instead. */
|
||||
status_t SetType(const char *mimeType);
|
||||
|
||||
private:
|
||||
BMimeType(const char *mimeType, const char *mimePath);
|
||||
// if mimePath is NULL, defaults to "/boot/home/config/settings/beos_mime/"
|
||||
|
||||
friend class MimeTypeTest;
|
||||
|
||||
// Uncomment, when needed...
|
||||
|
||||
// friend class BAppFileInfo;
|
||||
// friend class BRoster;
|
||||
// friend class TRosterApp;
|
||||
// friend class TMimeWorker;
|
||||
|
||||
// friend status_t _update_mime_info_(const char *, int32);
|
||||
// friend status_t _real_update_app_(BAppFileInfo *, const char *, bool);
|
||||
|
||||
// static void _set_local_dispatch_target_(BMessenger *, void (*)(BMessage *));
|
||||
// void _touch_();
|
||||
|
||||
virtual void _ReservedMimeType1();
|
||||
virtual void _ReservedMimeType2();
|
||||
virtual void _ReservedMimeType3();
|
||||
|
||||
BMimeType &operator=(const BMimeType &);
|
||||
BMimeType(const BMimeType &);
|
||||
|
||||
/*
|
||||
void InitData(const char *type);
|
||||
status_t OpenFile(bool create_file = false, dev_t dev = -1) const;
|
||||
status_t CloseFile() const;
|
||||
status_t GetSupportedTypes(BMessage *types);
|
||||
status_t SetSupportedTypes(const BMessage *types);
|
||||
void MimeChanged(int32 w, const char *type = NULL,
|
||||
bool large = true) const;
|
||||
*/
|
||||
|
||||
char *fType;
|
||||
BFile *fMeta;
|
||||
char *fMimePath; // Was: "void *_unused;"
|
||||
entry_ref fRef;
|
||||
int fWhere;
|
||||
status_t fCStatus;
|
||||
uint32 _reserved[3];
|
||||
};
|
||||
|
||||
|
||||
#endif // _sk_mime_type_h_
|
||||
@@ -0,0 +1,137 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file Node.h
|
||||
BNode and node_ref interface declarations.
|
||||
*/
|
||||
|
||||
#ifndef __sk_node_h__
|
||||
#define __sk_node_h__
|
||||
|
||||
#include <Statable.h>
|
||||
#include <StorageDefs.Private.h>
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
namespace OpenBeOS {
|
||||
#endif
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// node_ref
|
||||
//---------------------------------------------------------------
|
||||
|
||||
//! Reference structure to a particular vnode on a particular device
|
||||
/*! <b>node_ref</b> - A node reference.
|
||||
|
||||
@author <a href="mailto:[email protected]">Tyler Dauwalder</a>
|
||||
@author Be Inc.
|
||||
@version 0.0.0
|
||||
*/
|
||||
struct node_ref {
|
||||
node_ref();
|
||||
node_ref(const node_ref &ref);
|
||||
|
||||
bool operator==(const node_ref &ref) const;
|
||||
bool operator!=(const node_ref &ref) const;
|
||||
node_ref& operator=(const node_ref &ref);
|
||||
|
||||
dev_t device;
|
||||
ino_t node;
|
||||
};
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// BNode
|
||||
//---------------------------------------------------------------
|
||||
|
||||
//! A BNode represents a chunk of data in the filesystem.
|
||||
/*! The BNode class provides an interface for manipulating the data and attributes
|
||||
belonging to filesystem entries. The BNode is unaware of the name that refers
|
||||
to it in the filesystem (i.e. its entry); a BNode is solely concerned with
|
||||
the entry's data and attributes.
|
||||
|
||||
|
||||
@author <a href='mailto:[email protected]'>Tyler Dauwalder</a>
|
||||
@version 0.0.0
|
||||
|
||||
*/
|
||||
class BNode : public BStatable {
|
||||
public:
|
||||
|
||||
BNode();
|
||||
BNode(const entry_ref *ref);
|
||||
BNode(const BEntry *entry);
|
||||
BNode(const char *path);
|
||||
BNode(const BDirectory *dir, const char *path);
|
||||
BNode(const BNode &node);
|
||||
virtual ~BNode();
|
||||
|
||||
status_t InitCheck() const;
|
||||
|
||||
virtual status_t GetStat(struct stat *st) const;
|
||||
|
||||
status_t SetTo(const entry_ref *ref);
|
||||
status_t SetTo(const BEntry *entry);
|
||||
status_t SetTo(const char *path);
|
||||
status_t SetTo(const BDirectory *dir, const char *path);
|
||||
void Unset();
|
||||
|
||||
status_t Lock();
|
||||
status_t Unlock();
|
||||
|
||||
status_t Sync();
|
||||
|
||||
ssize_t WriteAttr(const char *name, type_code type, off_t offset,
|
||||
const void *buffer, size_t len);
|
||||
ssize_t ReadAttr(const char *name, type_code type, off_t offset,
|
||||
void *buffer, size_t len) const;
|
||||
status_t RemoveAttr(const char *name);
|
||||
status_t RenameAttr(const char *oldname, const char *newname);
|
||||
status_t GetAttrInfo(const char *name, struct attr_info *info) const;
|
||||
status_t GetNextAttrName(char *buffer);
|
||||
status_t RewindAttrs();
|
||||
status_t WriteAttrString(const char *name, const BString *data);
|
||||
status_t ReadAttrString(const char *name, BString *result) const;
|
||||
|
||||
BNode& operator=(const BNode &node);
|
||||
bool operator==(const BNode &node) const;
|
||||
bool operator!=(const BNode &node) const;
|
||||
|
||||
int Dup(); // This should be "const" but R5's is not... Ugggh.
|
||||
|
||||
private:
|
||||
friend class BFile;
|
||||
friend class BDirectory;
|
||||
friend class BSymLink;
|
||||
|
||||
virtual void _ReservedNode1();
|
||||
virtual void _ReservedNode2();
|
||||
virtual void _ReservedNode3();
|
||||
virtual void _ReservedNode4();
|
||||
virtual void _ReservedNode5();
|
||||
virtual void _ReservedNode6();
|
||||
|
||||
uint32 rudeData[4];
|
||||
|
||||
private:
|
||||
status_t set_fd(StorageKit::FileDescriptor fd);
|
||||
virtual void close_fd();
|
||||
void set_status(status_t newStatus);
|
||||
|
||||
virtual status_t set_stat(struct stat &st, uint32 what);
|
||||
|
||||
StorageKit::FileDescriptor fFd;
|
||||
StorageKit::FileDescriptor fAttrFd;
|
||||
status_t fCStatus;
|
||||
|
||||
status_t InitAttrDir();
|
||||
};
|
||||
|
||||
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
}; // namespace OpenBeOS
|
||||
#endif
|
||||
|
||||
#endif // __sk_node_h__
|
||||
@@ -0,0 +1,117 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file NodeInfo.h
|
||||
BNodeInfo interface declaration.
|
||||
*/
|
||||
|
||||
#ifndef __sk_node_info_h__
|
||||
#define __sk_node_info_h__
|
||||
|
||||
#ifndef _BE_BUILD_H
|
||||
#include <BeBuild.h>
|
||||
#endif
|
||||
#include <SupportDefs.h>
|
||||
#include <Mime.h>
|
||||
#include <Message.h>
|
||||
#include <File.h>
|
||||
#include <Entry.h>
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
namespace OpenBeOS {
|
||||
#endif // USE_OPENBEOS_NAMESPACE
|
||||
|
||||
class BBitmap;
|
||||
class BResources;
|
||||
|
||||
|
||||
//! BNodeInfo provides file type information
|
||||
/*! BNodeInfo provides a nice wrapper to all sorts of usefull meta data.
|
||||
* Like it's mime type, the files icon and the application which will load
|
||||
* the file.
|
||||
*
|
||||
* @see <a href="http://www.opensource.org/licenses/mit-license.html">MIT</a>
|
||||
* @author <a href="mailto:[email protected]"> Michael Lloyd Lee </a>
|
||||
* @author Be Inc
|
||||
* @version 0
|
||||
*/
|
||||
class BNodeInfo {
|
||||
public:
|
||||
|
||||
//! Uninitialized Constuctor
|
||||
/*! After created a BNodeInfo with this, you should call \sa SetTo()
|
||||
* @see SetTo(BNode *node)
|
||||
*/
|
||||
BNodeInfo();
|
||||
|
||||
//! The Constuctor
|
||||
/*! @see SetTo(BNode *node)
|
||||
* @param node The node to gather information on. Can be any favour */
|
||||
BNodeInfo(BNode *node);
|
||||
virtual ~BNodeInfo();
|
||||
|
||||
//! Sets the node for which you want data on
|
||||
/*! @param node The node to play with
|
||||
* @return <UL><li><code>B_OK</code>All is fine (still check InitCheck)</li>
|
||||
* <li><code>B_BAD_VALUE</code>The node was bad</li><ul>
|
||||
*/
|
||||
status_t SetTo(BNode *node);
|
||||
|
||||
//! Has it been created OK?
|
||||
/*! @returns <ul><li><code>B_OK</code></li>
|
||||
* <li><code>B_NO_INIT</code></li></ul>
|
||||
*/
|
||||
status_t InitCheck() const;
|
||||
|
||||
//! Gets the nodes MIME type
|
||||
virtual status_t GetType(char *type) const;
|
||||
//! Sets the nodes MIME type
|
||||
virtual status_t SetType(const char *type);
|
||||
//! Gets the nodes icon
|
||||
virtual status_t GetIcon(BBitmap *icon, icon_size k = B_LARGE_ICON) const;
|
||||
//! Sets the nodes icon
|
||||
virtual status_t SetIcon(const BBitmap *icon, icon_size k = B_LARGE_ICON);
|
||||
|
||||
//! Gets the application which will open the node when a user double-clicks
|
||||
status_t GetPreferredApp(char *signature,
|
||||
app_verb verb = B_OPEN) const;
|
||||
//! Sets the application which will open the node.
|
||||
status_t SetPreferredApp(const char *signature,
|
||||
app_verb verb = B_OPEN);
|
||||
//! Gets a entry_ref which may point to an application which will load when
|
||||
//! the user double clicks
|
||||
status_t GetAppHint(entry_ref *ref) const;
|
||||
//! Sets the entry_reg which should point to the app you wish to load when
|
||||
//! node (icon in tracker) is double clicked
|
||||
status_t SetAppHint(const entry_ref *ref);
|
||||
|
||||
//! Gets the icon which tracker displays
|
||||
status_t GetTrackerIcon(BBitmap *icon,
|
||||
icon_size k = B_LARGE_ICON) const;
|
||||
//! Sets the icon which tracker will desplay
|
||||
static status_t GetTrackerIcon(const entry_ref *ref,
|
||||
BBitmap *icon,
|
||||
icon_size k = B_LARGE_ICON);
|
||||
private:
|
||||
friend class BAppFileInfo;
|
||||
|
||||
virtual void _ReservedNodeInfo1(); //< FBC
|
||||
virtual void _ReservedNodeInfo2(); //< FBC
|
||||
virtual void _ReservedNodeInfo3(); //< FBC
|
||||
|
||||
BNodeInfo &operator=(const BNodeInfo &);
|
||||
BNodeInfo(const BNodeInfo &);
|
||||
|
||||
BNode *fNode; //< The Node in question
|
||||
uint32 _reserved[2]; //< FBC
|
||||
status_t fCStatus; //< The status to return from InitCheck
|
||||
};
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
}
|
||||
#endif // USE_OPENBEOS_NAMESPACE
|
||||
|
||||
#endif // __sk_node_info_h__
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file Path.h
|
||||
BPath interface declaration.
|
||||
*/
|
||||
|
||||
#ifndef __sk_path_h__
|
||||
#define __sk_path_h__
|
||||
|
||||
#include <Flattenable.h>
|
||||
#include <SupportDefs.h>
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
namespace OpenBeOS {
|
||||
#endif
|
||||
|
||||
// Forward declarations
|
||||
class BDirectory;
|
||||
class BEntry;
|
||||
struct entry_ref;
|
||||
|
||||
/*!
|
||||
\class BPath
|
||||
\brief An absolute pathname wrapper class
|
||||
|
||||
Provides a convenient means of managing pathnames.
|
||||
|
||||
\author <a href='mailto:[email protected]'>Ingo Weinhold</a>
|
||||
\author <a href="mailto:[email protected]">Tyler Dauwalder</a>
|
||||
|
||||
\version 0.0.0
|
||||
*/
|
||||
class BPath : public BFlattenable {
|
||||
public:
|
||||
|
||||
BPath();
|
||||
BPath(const BPath &path);
|
||||
BPath(const entry_ref *ref);
|
||||
BPath(const BEntry *entry);
|
||||
BPath(const char *dir, const char *leaf = NULL, bool normalize = false);
|
||||
BPath(const BDirectory *dir, const char *leaf, bool normalize = false);
|
||||
|
||||
virtual ~BPath();
|
||||
|
||||
status_t InitCheck() const;
|
||||
|
||||
status_t SetTo(const entry_ref *ref);
|
||||
status_t SetTo(const BEntry *entry);
|
||||
status_t SetTo(const char *path, const char *leaf = NULL,
|
||||
bool normalize = false);
|
||||
status_t SetTo(const BDirectory *dir, const char *path,
|
||||
bool normalize = false);
|
||||
void Unset();
|
||||
|
||||
status_t Append(const char *path, bool normalize = false);
|
||||
|
||||
const char *Path() const;
|
||||
const char *Leaf() const;
|
||||
status_t GetParent(BPath *path) const;
|
||||
|
||||
bool operator==(const BPath &item) const;
|
||||
bool operator==(const char *path) const;
|
||||
bool operator!=(const BPath &item) const;
|
||||
bool operator!=(const char *path) const;
|
||||
BPath& operator=(const BPath &item);
|
||||
BPath& operator=(const char *path);
|
||||
|
||||
// BFlattenable protocol
|
||||
virtual bool IsFixedSize() const;
|
||||
virtual type_code TypeCode() const;
|
||||
virtual ssize_t FlattenedSize() const;
|
||||
virtual status_t Flatten(void *buffer, ssize_t size) const;
|
||||
virtual bool AllowsTypeCode(type_code code) const;
|
||||
virtual status_t Unflatten(type_code c, const void *buf, ssize_t size);
|
||||
|
||||
private:
|
||||
virtual void _WarPath1();
|
||||
virtual void _WarPath2();
|
||||
virtual void _WarPath3();
|
||||
|
||||
uint32 _warData[4];
|
||||
|
||||
char *fName;
|
||||
status_t fCStatus;
|
||||
|
||||
class EBadInput { };
|
||||
|
||||
status_t set_path(const char *path);
|
||||
|
||||
static bool MustNormalize(const char *path);
|
||||
};
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
}; // namespace OpenBeOS
|
||||
#endif
|
||||
|
||||
#endif // __sk_path_h__
|
||||
@@ -0,0 +1,123 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file Query.h
|
||||
BQuery interface declaration.
|
||||
*/
|
||||
|
||||
#ifndef _sk_query_h_
|
||||
#define _sk_query_h_
|
||||
|
||||
#include <EntryList.h>
|
||||
#include <Messenger.h>
|
||||
#include <OS.h>
|
||||
#include <SupportDefs.h>
|
||||
|
||||
#include <StorageDefs.Private.h>
|
||||
|
||||
class BVolume;
|
||||
struct entry_ref;
|
||||
|
||||
namespace StorageKit {
|
||||
class QueryNode;
|
||||
class QueryStack;
|
||||
class QueryTree;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
B_INVALID_OP = 0,
|
||||
B_EQ,
|
||||
B_GT,
|
||||
B_GE,
|
||||
B_LT,
|
||||
B_LE,
|
||||
B_NE,
|
||||
B_CONTAINS,
|
||||
B_BEGINS_WITH,
|
||||
B_ENDS_WITH,
|
||||
B_AND = 0x101,
|
||||
B_OR,
|
||||
B_NOT,
|
||||
_B_RESERVED_OP_ = 0x100000
|
||||
} query_op;
|
||||
|
||||
/*!
|
||||
\class BQuery
|
||||
\brief Represents a live or non-live file system query
|
||||
|
||||
Provides an interface for creating file system queries. Implements
|
||||
the BEntryList for iterating through the found entries.
|
||||
|
||||
\author <a href='mailto:[email protected]'>Ingo Weinhold</a>
|
||||
|
||||
\version 0.0.0
|
||||
*/
|
||||
class BQuery : public BEntryList {
|
||||
public:
|
||||
BQuery();
|
||||
virtual ~BQuery();
|
||||
|
||||
status_t Clear();
|
||||
|
||||
status_t PushAttr(const char *attrName);
|
||||
status_t PushOp(query_op op);
|
||||
|
||||
status_t PushUInt32(uint32 value);
|
||||
status_t PushInt32(int32 value);
|
||||
status_t PushUInt64(uint64 value);
|
||||
status_t PushInt64(int64 value);
|
||||
status_t PushFloat(float value);
|
||||
status_t PushDouble(double value);
|
||||
status_t PushString(const char *value, bool caseInsensitive = false);
|
||||
status_t PushDate(const char *date);
|
||||
|
||||
status_t SetVolume(const BVolume *volume);
|
||||
status_t SetPredicate(const char *expression);
|
||||
status_t SetTarget(BMessenger messenger);
|
||||
|
||||
bool IsLive() const;
|
||||
|
||||
status_t GetPredicate(char *buffer, size_t length);
|
||||
status_t GetPredicate(BString *predicate);
|
||||
size_t PredicateLength();
|
||||
|
||||
dev_t TargetDevice() const;
|
||||
|
||||
status_t Fetch();
|
||||
|
||||
// BEntryList interface
|
||||
virtual status_t GetNextEntry(BEntry *entry, bool traverse = false);
|
||||
virtual status_t GetNextRef(entry_ref *ref);
|
||||
virtual int32 GetNextDirents(struct dirent *buf, size_t length,
|
||||
int32 count = INT_MAX);
|
||||
virtual status_t Rewind();
|
||||
virtual int32 CountEntries();
|
||||
|
||||
private:
|
||||
bool _HasFetched() const;
|
||||
status_t _PushNode(StorageKit::QueryNode *node, bool deleteOnError);
|
||||
status_t _SetPredicate(const char *expression);
|
||||
status_t _EvaluateStack();
|
||||
|
||||
// FBC
|
||||
virtual void _ReservedQuery1();
|
||||
virtual void _ReservedQuery2();
|
||||
virtual void _ReservedQuery3();
|
||||
virtual void _ReservedQuery4();
|
||||
virtual void _ReservedQuery5();
|
||||
virtual void _ReservedQuery6();
|
||||
|
||||
private:
|
||||
int32 _reservedData[4]; // FBC
|
||||
StorageKit::QueryStack *fStack;
|
||||
char *fPredicate;
|
||||
dev_t fDevice;
|
||||
bool fLive;
|
||||
port_id fPort;
|
||||
long fToken;
|
||||
StorageKit::FileDescriptor fQueryFd;
|
||||
};
|
||||
|
||||
#endif // _sk_query_h_
|
||||
@@ -0,0 +1,90 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file ResourceStrings.h
|
||||
BResourceStrings interface declaration.
|
||||
*/
|
||||
|
||||
#ifndef _sk_resource_strings_h_
|
||||
#define _sk_resource_strings_h_
|
||||
|
||||
#include <Entry.h>
|
||||
#include <Locker.h>
|
||||
|
||||
class BResources;
|
||||
class BString;
|
||||
|
||||
/*!
|
||||
\class BResourceStrings
|
||||
\brief Simple class to access the string resources in a file.
|
||||
|
||||
A BResourceStrings object reads the string type resources from a given
|
||||
resource file and provides fast read only access to them.
|
||||
|
||||
\author <a href='mailto:[email protected]'>Ingo Weinhold</a>
|
||||
|
||||
\version 0.0.0
|
||||
*/
|
||||
class BResourceStrings {
|
||||
public:
|
||||
BResourceStrings();
|
||||
BResourceStrings(const entry_ref &ref);
|
||||
virtual ~BResourceStrings();
|
||||
|
||||
status_t InitCheck();
|
||||
virtual BString *NewString(int32 id);
|
||||
virtual const char *FindString(int32 id);
|
||||
|
||||
virtual status_t SetStringFile(const entry_ref *ref);
|
||||
status_t GetStringFile(entry_ref *outRef);
|
||||
|
||||
public:
|
||||
enum {
|
||||
RESOURCE_TYPE = 'CSTR'
|
||||
};
|
||||
|
||||
protected:
|
||||
struct _string_id_hash {
|
||||
_string_id_hash();
|
||||
~_string_id_hash();
|
||||
void assign_string(const char *str, bool makeCopy);
|
||||
_string_id_hash *next;
|
||||
int32 id;
|
||||
char *data;
|
||||
bool data_alloced;
|
||||
bool _reserved1[3];
|
||||
uint32 _reserved2;
|
||||
};
|
||||
|
||||
protected:
|
||||
BLocker _string_lock;
|
||||
status_t _init_error;
|
||||
|
||||
private:
|
||||
entry_ref fFileRef;
|
||||
BResources *fResources;
|
||||
_string_id_hash **fHashTable;
|
||||
int32 fHashTableSize;
|
||||
int32 fStringCount;
|
||||
uint32 _reserved[16]; // FBC
|
||||
|
||||
private:
|
||||
void _Cleanup();
|
||||
void _MakeEmpty();
|
||||
status_t _Rehash(int32 newSize);
|
||||
_string_id_hash *_AddString(char *str, int32 id, bool wasMalloced);
|
||||
|
||||
virtual _string_id_hash *_FindString(int32 id);
|
||||
|
||||
// FBC
|
||||
virtual void _ReservedResourceStrings0();
|
||||
virtual void _ReservedResourceStrings1();
|
||||
virtual void _ReservedResourceStrings2();
|
||||
virtual void _ReservedResourceStrings3();
|
||||
virtual void _ReservedResourceStrings4();
|
||||
virtual void _ReservedResourceStrings5();
|
||||
};
|
||||
|
||||
#endif // _sk_resource_strings_h_
|
||||
@@ -0,0 +1,114 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file Resources.h
|
||||
BResources interface declaration.
|
||||
*/
|
||||
|
||||
#ifndef _sk_resources_h_
|
||||
#define _sk_resources_h_
|
||||
|
||||
#include <File.h>
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
namespace OpenBeOS {
|
||||
#endif
|
||||
|
||||
namespace StorageKit {
|
||||
class ResourcesContainer;
|
||||
class ResourceFile;
|
||||
};
|
||||
|
||||
/*!
|
||||
\class BResources
|
||||
\brief Represent the resources in a file
|
||||
|
||||
Provides an interface for accessing and manipulating resources.
|
||||
|
||||
\author <a href='mailto:[email protected]'>Ingo Weinhold</a>
|
||||
|
||||
\version 0.0.0
|
||||
*/
|
||||
class BResources {
|
||||
public:
|
||||
BResources();
|
||||
BResources(const BFile *file, bool clobber = false);
|
||||
virtual ~BResources();
|
||||
|
||||
status_t SetTo(const BFile *file, bool clobber = false);
|
||||
void Unset();
|
||||
status_t InitCheck() const;
|
||||
|
||||
const BFile &File() const;
|
||||
|
||||
const void *LoadResource(type_code type, int32 id, size_t *outSize);
|
||||
const void *LoadResource(type_code type, const char *name,
|
||||
size_t *outSize);
|
||||
|
||||
status_t PreloadResourceType(type_code type = 0);
|
||||
|
||||
status_t Sync();
|
||||
status_t MergeFrom(BFile *fromFile);
|
||||
status_t WriteTo(BFile *file);
|
||||
|
||||
status_t AddResource(type_code type, int32 id, const void *data,
|
||||
size_t length, const char *name = NULL);
|
||||
|
||||
bool HasResource(type_code type, int32 id);
|
||||
bool HasResource(type_code type, const char *name);
|
||||
|
||||
bool GetResourceInfo(int32 byIndex, type_code *typeFound, int32 *idFound,
|
||||
const char **nameFound, size_t *lengthFound);
|
||||
bool GetResourceInfo(type_code byType, int32 andIndex, int32 *idFound,
|
||||
const char **nameFound, size_t *lengthFound);
|
||||
bool GetResourceInfo(type_code byType, int32 andID,
|
||||
const char **nameFound, size_t *lengthFound);
|
||||
bool GetResourceInfo(type_code byType, const char *andName, int32 *idFound,
|
||||
size_t *lengthFound);
|
||||
bool GetResourceInfo(const void *byPointer, type_code *typeFound,
|
||||
int32 *idFound, size_t *lengthFound,
|
||||
const char **nameFound);
|
||||
|
||||
status_t RemoveResource(const void *resource);
|
||||
status_t RemoveResource(type_code type, int32 id);
|
||||
|
||||
|
||||
// deprecated
|
||||
|
||||
status_t WriteResource(type_code type, int32 id, const void *data,
|
||||
off_t offset, size_t length);
|
||||
|
||||
status_t ReadResource(type_code type, int32 id, void *data, off_t offset,
|
||||
size_t length);
|
||||
|
||||
void *FindResource(type_code type, int32 id, size_t *lengthFound);
|
||||
void *FindResource(type_code type, const char *name, size_t *lengthFound);
|
||||
|
||||
private:
|
||||
// FBC
|
||||
virtual void _ReservedResources1();
|
||||
virtual void _ReservedResources2();
|
||||
virtual void _ReservedResources3();
|
||||
virtual void _ReservedResources4();
|
||||
virtual void _ReservedResources5();
|
||||
virtual void _ReservedResources6();
|
||||
virtual void _ReservedResources7();
|
||||
virtual void _ReservedResources8();
|
||||
|
||||
private:
|
||||
BFile fFile;
|
||||
StorageKit::ResourcesContainer *fContainer;
|
||||
StorageKit::ResourceFile *fResourceFile;
|
||||
bool fReadOnly;
|
||||
bool _pad[3];
|
||||
uint32 _reserved[3]; // FBC
|
||||
};
|
||||
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
}; // namespace OpenBeOS
|
||||
#endif
|
||||
|
||||
#endif // _sk_resources_h_
|
||||
@@ -0,0 +1,83 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file Statable.h
|
||||
BStatable interface declaration.
|
||||
*/
|
||||
|
||||
#ifndef __sk_statable_h__
|
||||
#define __sk_statable_h__
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <SupportDefs.h>
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
namespace OpenBeOS {
|
||||
#endif // USE_OPENBEOS_NAMESPACE
|
||||
|
||||
struct node_ref;
|
||||
class BVolume;
|
||||
|
||||
|
||||
//! BStatable - A nice C++ wrapper to <code>\sa stat()</code>
|
||||
/*! A purly abstract class which provieds an expenive, but convenet
|
||||
* C++ wrapper to the posix <code>\sa stat()</code> command.
|
||||
*
|
||||
* @see <a href="http://www.opensource.org/licenses/mit-license.html">MIT</a>
|
||||
* @author <a href="mailto:[email protected]"> Michael Lloyd Lee </a>
|
||||
* @author Be Inc
|
||||
* @version 0
|
||||
*/
|
||||
class BStatable {
|
||||
public:
|
||||
virtual status_t GetStat(struct stat *st) const = 0;
|
||||
|
||||
bool IsFile() const;
|
||||
bool IsDirectory() const;
|
||||
bool IsSymLink() const;
|
||||
|
||||
status_t GetNodeRef(node_ref *ref) const;
|
||||
|
||||
status_t GetOwner(uid_t *owner) const;
|
||||
status_t SetOwner(uid_t owner);
|
||||
|
||||
status_t GetGroup(gid_t *group) const;
|
||||
status_t SetGroup(gid_t group);
|
||||
|
||||
status_t GetPermissions(mode_t *perms) const;
|
||||
status_t SetPermissions(mode_t perms);
|
||||
|
||||
status_t GetSize(off_t *size) const;
|
||||
|
||||
status_t GetModificationTime(time_t *mtime) const;
|
||||
status_t SetModificationTime(time_t mtime);
|
||||
|
||||
status_t GetCreationTime(time_t *ctime) const;
|
||||
status_t SetCreationTime(time_t ctime);
|
||||
|
||||
status_t GetAccessTime(time_t *atime) const;
|
||||
status_t SetAccessTime(time_t atime);
|
||||
|
||||
status_t GetVolume(BVolume *vol) const;
|
||||
|
||||
private:
|
||||
|
||||
friend class BEntry;
|
||||
friend class BNode;
|
||||
|
||||
virtual void _OhSoStatable1(); //< FBC
|
||||
virtual void _OhSoStatable2(); //< FBC
|
||||
virtual void _OhSoStatable3(); //< FBC
|
||||
uint32 _ohSoData[4]; //< FBC
|
||||
|
||||
virtual status_t set_stat(struct stat &st, uint32 what) = 0;
|
||||
};
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
}
|
||||
#endif // USE_OPENBEOS_NAMESPACE
|
||||
|
||||
#endif // __sk_statable_h__
|
||||
@@ -0,0 +1,56 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file StorageDefs.h
|
||||
Miscellaneous Storage Kit definitions and includes.
|
||||
*/
|
||||
|
||||
#ifndef __sk_def_storage_h__
|
||||
#define __sk_def_storage_h__
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/param.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
namespace OpenBeOS {
|
||||
#endif // USE_OPENBEOS_NAMESPACE
|
||||
|
||||
// Limits
|
||||
#define B_DEV_NAME_LENGTH 128
|
||||
#define B_FILE_NAME_LENGTH NAME_MAX
|
||||
#define B_PATH_NAME_LENGTH MAXPATHLEN
|
||||
#define B_ATTR_NAME_LENGTH (B_FILE_NAME_LENGTH-1)
|
||||
#define B_MIME_TYPE_LENGTH (B_ATTR_NAME_LENGTH - 15)
|
||||
#define B_MAX_SYMLINKS SYMLINK_MAX
|
||||
|
||||
|
||||
// Open Modes
|
||||
#define B_READ_ONLY O_RDONLY // read only
|
||||
#define B_WRITE_ONLY O_WRONLY // write only
|
||||
#define B_READ_WRITE O_RDWR // read and write
|
||||
|
||||
#define B_FAIL_IF_EXISTS O_EXCL // exclusive create
|
||||
#define B_CREATE_FILE O_CREAT // create the file
|
||||
#define B_ERASE_FILE O_TRUNC // erase the file's data
|
||||
#define B_OPEN_AT_END O_APPEND // point to the end of the data
|
||||
|
||||
|
||||
// Node Flavors
|
||||
enum node_flavor {
|
||||
B_FILE_NODE = 0x01,
|
||||
B_SYMLINK_NODE = 0x02,
|
||||
B_DIRECTORY_NODE = 0x04,
|
||||
B_ANY_NODE = 0x07
|
||||
};
|
||||
|
||||
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
}; // namespace OpenBeOS
|
||||
#endif // USE_OPENBEOS_NAMESPACE
|
||||
|
||||
|
||||
#endif __sk_def_storage_h__
|
||||
@@ -0,0 +1,87 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// File Name: SymLink.h
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file SymLink.h
|
||||
BSymLink interface declaration.
|
||||
*/
|
||||
|
||||
#ifndef __sk_sym_link_h__
|
||||
#define __sk_sym_link_h__
|
||||
|
||||
#include <Node.h>
|
||||
#include <StorageDefs.h>
|
||||
#include "kernel_interface.h"
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
namespace OpenBeOS {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
\class BSymLink
|
||||
\brief A symbolic link in the filesystem
|
||||
|
||||
Provides an interface for manipulating symbolic links.
|
||||
|
||||
\author <a href='mailto:bonefish@users.sf.net'>Ingo Weinhold</a>
|
||||
|
||||
\version 0.0.0
|
||||
*/
|
||||
class BSymLink : public BNode {
|
||||
public:
|
||||
BSymLink();
|
||||
BSymLink(const BSymLink &link);
|
||||
BSymLink(const entry_ref *ref);
|
||||
BSymLink(const BEntry *entry);
|
||||
BSymLink(const char *path);
|
||||
BSymLink(const BDirectory *dir, const char *path);
|
||||
virtual ~BSymLink();
|
||||
|
||||
// WORKAROUND
|
||||
// SetTo() methods: Part of a work around until someone has an idea how to
|
||||
// get StorageKit::read_link(FileDescriptor,...) to work.
|
||||
status_t SetTo(const entry_ref *ref);
|
||||
status_t SetTo(const BEntry *entry);
|
||||
status_t SetTo(const char *path);
|
||||
status_t SetTo(const BDirectory *dir, const char *path);
|
||||
void Unset();
|
||||
|
||||
ssize_t ReadLink(char *buf, size_t size);
|
||||
|
||||
ssize_t MakeLinkedPath(const char *dirPath, BPath *path);
|
||||
ssize_t MakeLinkedPath(const BDirectory *dir, BPath *path);
|
||||
|
||||
bool IsAbsolute();
|
||||
|
||||
// WORKAROUND
|
||||
// operator=(): Part of a work around until someone has an idea how to
|
||||
// get StorageKit::read_link(FileDescriptor,...) to work.
|
||||
BSymLink &operator=(const BSymLink &link);
|
||||
|
||||
private:
|
||||
virtual void _ReservedSymLink1();
|
||||
virtual void _ReservedSymLink2();
|
||||
virtual void _ReservedSymLink3();
|
||||
virtual void _ReservedSymLink4();
|
||||
virtual void _ReservedSymLink5();
|
||||
virtual void _ReservedSymLink6();
|
||||
|
||||
// WORKAROUND
|
||||
// fSecretEntry: Part of a work around until someone has an idea how to
|
||||
// get StorageKit::read_link(FileDescriptor,...) to work.
|
||||
// uint32 _reservedData[4];
|
||||
uint32 _reservedData[3];
|
||||
BEntry *fSecretEntry;
|
||||
|
||||
private:
|
||||
StorageKit::FileDescriptor get_fd() const;
|
||||
};
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
}; // namespace OpenBeOS
|
||||
#endif
|
||||
|
||||
#endif // __sk_sym_link_h__
|
||||
@@ -0,0 +1,109 @@
|
||||
// ----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
// File Name: Directory.cpp
|
||||
//
|
||||
// Description: BVolume class
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#ifndef __sk_volume_h__
|
||||
#define __sk_volume_h__
|
||||
|
||||
#ifndef _BE_BUILD_H
|
||||
#include <BeBuild.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef _FS_INFO_H
|
||||
#include <fs_info.h>
|
||||
//#include "fs_info.h"
|
||||
#endif
|
||||
#ifndef _STORAGE_DEFS_H
|
||||
#include <StorageDefs.h>
|
||||
//#include "StorageDefs.h"
|
||||
#endif
|
||||
#ifndef _MIME_H
|
||||
#include <Mime.h>
|
||||
#endif
|
||||
#ifndef _SUPPORT_DEFS_H
|
||||
#include <SupportDefs.h>
|
||||
#endif
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
namespace OpenBeOS {
|
||||
#endif
|
||||
|
||||
|
||||
class BDirectory;
|
||||
class BBitmap;
|
||||
|
||||
class BVolume {
|
||||
public:
|
||||
BVolume(void);
|
||||
BVolume(dev_t dev);
|
||||
BVolume(const BVolume& vol);
|
||||
|
||||
virtual ~BVolume(void);
|
||||
|
||||
status_t InitCheck(void) const;
|
||||
|
||||
status_t SetTo(dev_t dev);
|
||||
void Unset(void);
|
||||
|
||||
dev_t Device(void) const;
|
||||
|
||||
status_t GetRootDirectory(BDirectory* dir) const;
|
||||
|
||||
off_t Capacity(void) const;
|
||||
off_t FreeBytes(void) const;
|
||||
|
||||
status_t GetName(char* name) const;
|
||||
status_t SetName(const char* name);
|
||||
|
||||
status_t GetIcon(
|
||||
BBitmap* icon,
|
||||
icon_size which) const;
|
||||
|
||||
bool IsRemovable(void) const;
|
||||
bool IsReadOnly(void) const;
|
||||
bool IsPersistent(void) const;
|
||||
bool IsShared(void) const;
|
||||
bool KnowsMime(void) const;
|
||||
bool KnowsAttr(void) const;
|
||||
bool KnowsQuery(void) const;
|
||||
|
||||
bool operator==(const BVolume& vol) const;
|
||||
bool operator!=(const BVolume& vol) const;
|
||||
BVolume& operator=(const BVolume& vol);
|
||||
|
||||
private:
|
||||
|
||||
friend class BVolumeRoster;
|
||||
|
||||
virtual void _TurnUpTheVolume1();
|
||||
virtual void _TurnUpTheVolume2();
|
||||
|
||||
#if !_PR3_COMPATIBLE_
|
||||
virtual void _TurnUpTheVolume3();
|
||||
virtual void _TurnUpTheVolume4();
|
||||
virtual void _TurnUpTheVolume5();
|
||||
virtual void _TurnUpTheVolume6();
|
||||
virtual void _TurnUpTheVolume7();
|
||||
virtual void _TurnUpTheVolume8();
|
||||
#endif
|
||||
|
||||
dev_t fDev;
|
||||
status_t fCStatus;
|
||||
|
||||
#if !_PR3_COMPATIBLE_
|
||||
int32 _reserved[8];
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user