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,105 @@
|
||||
// Elf.h
|
||||
|
||||
#ifndef _sk_elf_h_
|
||||
#define _sk_elf_h_
|
||||
|
||||
// types
|
||||
typedef uint32 Elf32_Addr;
|
||||
typedef uint16 Elf32_Half;
|
||||
typedef uint32 Elf32_Off;
|
||||
typedef int32 Elf32_Sword;
|
||||
typedef uint32 Elf32_Word;
|
||||
|
||||
// e_ident indices
|
||||
#define EI_MAG0 0
|
||||
#define EI_MAG1 1
|
||||
#define EI_MAG2 2
|
||||
#define EI_MAG3 3
|
||||
#define EI_CLASS 4
|
||||
#define EI_DATA 5
|
||||
#define EI_VERSION 6
|
||||
#define EI_PAD 7
|
||||
#define EI_NIDENT 16
|
||||
|
||||
// object file header
|
||||
typedef struct {
|
||||
unsigned char e_ident[EI_NIDENT];
|
||||
Elf32_Half e_type;
|
||||
Elf32_Half e_machine;
|
||||
Elf32_Word e_version;
|
||||
Elf32_Addr e_entry;
|
||||
Elf32_Off e_phoff;
|
||||
Elf32_Off e_shoff;
|
||||
Elf32_Word e_flags;
|
||||
Elf32_Half e_ehsize;
|
||||
Elf32_Half e_phentsize;
|
||||
Elf32_Half e_phnum;
|
||||
Elf32_Half e_shentsize;
|
||||
Elf32_Half e_shnum;
|
||||
Elf32_Half e_shstrndx;
|
||||
} Elf32_Ehdr;
|
||||
|
||||
// e_ident EI_CLASS and EI_DATA values
|
||||
#define ELFCLASSNONE 0
|
||||
#define ELFCLASS32 1
|
||||
#define ELFCLASS64 2
|
||||
#define ELFDATANONE 0
|
||||
#define ELFDATA2LSB 1
|
||||
#define ELFDATA2MSB 2
|
||||
|
||||
// program header
|
||||
typedef struct {
|
||||
Elf32_Word p_type;
|
||||
Elf32_Off p_offset;
|
||||
Elf32_Addr p_vaddr;
|
||||
Elf32_Addr p_paddr;
|
||||
Elf32_Word p_filesz;
|
||||
Elf32_Word p_memsz;
|
||||
Elf32_Word p_flags;
|
||||
Elf32_Word p_align;
|
||||
} Elf32_Phdr;
|
||||
|
||||
// p_type
|
||||
#define PT_NULL 0
|
||||
#define PT_LOAD 1
|
||||
#define PT_DYNAMIC 2
|
||||
#define PT_INTERP 3
|
||||
#define PT_NOTE 4
|
||||
#define PT_SHLIB 5
|
||||
#define PT_PHDIR 6
|
||||
#define PT_LOPROC 0x70000000
|
||||
#define PT_HIPROC 0x7fffffff
|
||||
|
||||
// section header
|
||||
typedef struct {
|
||||
Elf32_Word sh_name;
|
||||
Elf32_Word sh_type;
|
||||
Elf32_Word sh_flags;
|
||||
Elf32_Addr sh_addr;
|
||||
Elf32_Off sh_offset;
|
||||
Elf32_Word sh_size;
|
||||
Elf32_Word sh_link;
|
||||
Elf32_Word sh_info;
|
||||
Elf32_Word sh_addralign;
|
||||
Elf32_Word sh_entsize;
|
||||
} Elf32_Shdr;
|
||||
|
||||
// sh_type values
|
||||
#define SHT_NULL 0
|
||||
#define SHT_PROGBITS 1
|
||||
#define SHT_SYMTAB 2
|
||||
#define SHT_STRTAB 3
|
||||
#define SHT_RELA 4
|
||||
#define SHT_HASH 5
|
||||
#define SHT_DYNAMIC 6
|
||||
#define SHT_NOTE 7
|
||||
#define SHT_NOBITS 8
|
||||
#define SHT_REL 9
|
||||
#define SHT_SHLIB 10
|
||||
#define SHT_DYNSYM 11
|
||||
#define SHT_LOPROC 0x70000000
|
||||
#define SHT_HIPROC 0x7fffffff
|
||||
#define SHT_LOUSER 0x80000000
|
||||
#define SHT_HIUSER 0xffffffff
|
||||
|
||||
#endif // _sk_elf_h_
|
||||
@@ -0,0 +1,111 @@
|
||||
// Exception
|
||||
|
||||
#ifndef _sk_exception_
|
||||
#define _sk_exception_
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <String.h>
|
||||
|
||||
namespace StorageKit {
|
||||
|
||||
class Exception {
|
||||
public:
|
||||
// constructor
|
||||
Exception()
|
||||
: fError(B_OK),
|
||||
fDescription()
|
||||
{
|
||||
}
|
||||
|
||||
// constructor
|
||||
Exception(BString description)
|
||||
: fError(B_OK),
|
||||
fDescription(description)
|
||||
{
|
||||
}
|
||||
|
||||
// constructor
|
||||
Exception(const char* format,...)
|
||||
: fError(B_OK),
|
||||
fDescription()
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
SetTo(B_OK, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
// constructor
|
||||
Exception(status_t error)
|
||||
: fError(error),
|
||||
fDescription()
|
||||
{
|
||||
}
|
||||
|
||||
// constructor
|
||||
Exception(status_t error, BString description)
|
||||
: fError(error),
|
||||
fDescription(description)
|
||||
{
|
||||
}
|
||||
|
||||
// constructor
|
||||
Exception(status_t error, const char* format,...)
|
||||
: fError(error),
|
||||
fDescription()
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
SetTo(error, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
// copy constructor
|
||||
Exception(const Exception& exception)
|
||||
: fError(exception.fError),
|
||||
fDescription(exception.fDescription)
|
||||
{
|
||||
}
|
||||
|
||||
// destructor
|
||||
~Exception()
|
||||
{
|
||||
}
|
||||
|
||||
// SetTo
|
||||
void SetTo(status_t error, BString description)
|
||||
{
|
||||
fError = error;
|
||||
fDescription.SetTo(description);
|
||||
}
|
||||
|
||||
// SetTo
|
||||
void SetTo(status_t error, const char* format, va_list arg)
|
||||
{
|
||||
char buffer[2048];
|
||||
vsprintf(buffer, format, arg);
|
||||
SetTo(error, BString(buffer));
|
||||
}
|
||||
|
||||
// GetError
|
||||
status_t Error() const
|
||||
{
|
||||
return fError;
|
||||
}
|
||||
|
||||
// GetDescription
|
||||
const char* Description() const
|
||||
{
|
||||
return fDescription.String();
|
||||
}
|
||||
|
||||
private:
|
||||
status_t fError;
|
||||
BString fDescription;
|
||||
};
|
||||
|
||||
}; // namespace StorageKit
|
||||
|
||||
#endif // _sk_exception_
|
||||
@@ -0,0 +1,19 @@
|
||||
// LibBeAdapter.h
|
||||
|
||||
#ifndef _sk_lib_be_adapter_h_
|
||||
#define _sk_lib_be_adapter_h_
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
struct entry_ref;
|
||||
|
||||
extern status_t entry_ref_to_path_adapter(dev_t device, ino_t directory,
|
||||
const char *name,
|
||||
char *buffer, size_t size);
|
||||
|
||||
extern status_t swap_data_adapter(type_code type, void *data, size_t length,
|
||||
swap_action action);
|
||||
|
||||
extern bool is_type_swapped_adapter(type_code type);
|
||||
|
||||
#endif // _sk_lib_be_adapter_h_
|
||||
@@ -0,0 +1,63 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file OffsetFile.h
|
||||
OffsetFile interface declaration.
|
||||
*/
|
||||
|
||||
#ifndef _sk_offset_file_h_
|
||||
#define _sk_offset_file_h_
|
||||
|
||||
#include <DataIO.h>
|
||||
#include <File.h>
|
||||
|
||||
namespace StorageKit {
|
||||
|
||||
/*!
|
||||
\class OffsetFile
|
||||
\brief Provides access to a file skipping a certain amount of bytes at
|
||||
the beginning.
|
||||
|
||||
This class implements the BPositionIO interface to provide access to the
|
||||
data of a file past a certain offset. This is very handy e.g. for dealing
|
||||
with resources, as they always reside at the end of a file, but may start
|
||||
at arbitrary offsets.
|
||||
|
||||
\author <a href='mailto:[email protected]'>Ingo Weinhold</a>
|
||||
|
||||
\version 0.0.0
|
||||
*/
|
||||
class OffsetFile : public BPositionIO {
|
||||
public:
|
||||
OffsetFile();
|
||||
OffsetFile(BFile *file, off_t offset);
|
||||
virtual ~OffsetFile();
|
||||
|
||||
status_t SetTo(BFile *file, off_t offset);
|
||||
void Unset();
|
||||
status_t InitCheck() const;
|
||||
|
||||
BFile *File() const;
|
||||
|
||||
ssize_t ReadAt(off_t pos, void *buffer, size_t size);
|
||||
ssize_t WriteAt(off_t pos, const void *buffer,
|
||||
size_t size);
|
||||
off_t Seek(off_t position, uint32 seekMode);
|
||||
off_t Position() const;
|
||||
|
||||
status_t SetSize(off_t size);
|
||||
status_t GetSize(off_t *size);
|
||||
|
||||
off_t Offset() const;
|
||||
|
||||
private:
|
||||
BFile* fFile;
|
||||
off_t fOffset;
|
||||
off_t fCurrentPosition;
|
||||
};
|
||||
|
||||
}; // namespace StorageKit
|
||||
|
||||
#endif // _sk_offset_file_h_
|
||||
@@ -0,0 +1,46 @@
|
||||
// Pef.h
|
||||
|
||||
#ifndef _sk_pef_h_
|
||||
#define _sk_pef_h_
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
typedef char PefOSType[4];
|
||||
|
||||
// container header
|
||||
struct PEFContainerHeader {
|
||||
PefOSType tag1;
|
||||
PefOSType tag2;
|
||||
PefOSType architecture;
|
||||
uint32 formatVersion;
|
||||
uint32 dateTimeStamp;
|
||||
uint32 oldDefVersion;
|
||||
uint32 oldImpVersion;
|
||||
uint32 currentVersion;
|
||||
uint16 sectionCount;
|
||||
uint16 instSectionCount;
|
||||
uint32 reservedA;
|
||||
};
|
||||
|
||||
const char kPEFFileMagic1[4] = { 'J', 'o', 'y', '!' };
|
||||
const char kPEFFileMagic2[4] = { 'p', 'e', 'f', 'f' };
|
||||
const char kPEFArchitecturePPC[4] = { 'p', 'w', 'p', 'c' };
|
||||
const char kPEFContainerHeaderSize = 40;
|
||||
|
||||
// section header
|
||||
struct PEFSectionHeader {
|
||||
int32 nameOffset;
|
||||
uint32 defaultAddress;
|
||||
uint32 totalSize;
|
||||
uint32 unpackedSize;
|
||||
uint32 packedSize;
|
||||
uint32 containerOffset;
|
||||
uint8 sectionKind;
|
||||
uint8 shareKind;
|
||||
uint8 alignment;
|
||||
uint8 reservedA;
|
||||
};
|
||||
|
||||
const uint32 kPEFSectionHeaderSize = 28;
|
||||
|
||||
#endif // _sk_pef_h_
|
||||
@@ -0,0 +1,206 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file QueryPredicate.h
|
||||
BQuery predicate helper classes interface declaration.
|
||||
*/
|
||||
#ifndef _sk_query_predicate_h_
|
||||
#define _sk_query_predicate_h_
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <List.h>
|
||||
#include <Query.h>
|
||||
#include <String.h>
|
||||
|
||||
namespace StorageKit {
|
||||
|
||||
// QueryNode
|
||||
class QueryNode {
|
||||
public:
|
||||
QueryNode();
|
||||
virtual ~QueryNode();
|
||||
|
||||
virtual uint32 Arity() const = 0;
|
||||
virtual status_t SetChildAt(QueryNode *child, int32 index) = 0;
|
||||
virtual QueryNode *ChildAt(int32 index) = 0;
|
||||
|
||||
virtual status_t GetString(BString &predicate) = 0;
|
||||
};
|
||||
|
||||
// LeafNode
|
||||
class LeafNode : public QueryNode {
|
||||
public:
|
||||
LeafNode();
|
||||
virtual ~LeafNode();
|
||||
|
||||
virtual uint32 Arity() const;
|
||||
virtual status_t SetChildAt(QueryNode *child, int32 index);
|
||||
virtual QueryNode *ChildAt(int32 index);
|
||||
};
|
||||
|
||||
// UnaryNode
|
||||
class UnaryNode : public QueryNode {
|
||||
public:
|
||||
UnaryNode();
|
||||
virtual ~UnaryNode();
|
||||
|
||||
virtual uint32 Arity() const;
|
||||
virtual status_t SetChildAt(QueryNode *child, int32 index);
|
||||
virtual QueryNode *ChildAt(int32 index);
|
||||
|
||||
protected:
|
||||
QueryNode *fChild;
|
||||
};
|
||||
|
||||
// BinaryNode
|
||||
class BinaryNode : public QueryNode {
|
||||
public:
|
||||
BinaryNode();
|
||||
virtual ~BinaryNode();
|
||||
|
||||
virtual uint32 Arity() const;
|
||||
virtual status_t SetChildAt(QueryNode *child, int32 index);
|
||||
virtual QueryNode *ChildAt(int32 index);
|
||||
|
||||
protected:
|
||||
QueryNode *fChild1;
|
||||
QueryNode *fChild2;
|
||||
};
|
||||
|
||||
// AttributeNode
|
||||
class AttributeNode : public LeafNode {
|
||||
public:
|
||||
AttributeNode(const char *attribute);
|
||||
|
||||
virtual status_t GetString(BString &predicate);
|
||||
|
||||
private:
|
||||
BString fAttribute;
|
||||
};
|
||||
|
||||
// StringNode
|
||||
class StringNode : public LeafNode {
|
||||
public:
|
||||
StringNode(const char *value, bool caseInsensitive = false);
|
||||
|
||||
virtual status_t GetString(BString &predicate);
|
||||
|
||||
inline const char *Value() const { return fValue.String(); }
|
||||
|
||||
private:
|
||||
BString fValue;
|
||||
};
|
||||
|
||||
// DateNode
|
||||
class DateNode : public LeafNode {
|
||||
public:
|
||||
DateNode(const char *value);
|
||||
|
||||
virtual status_t GetString(BString &predicate);
|
||||
|
||||
private:
|
||||
BString fValue;
|
||||
};
|
||||
|
||||
// ValueNode
|
||||
template<typename ValueType>
|
||||
class ValueNode : public LeafNode {
|
||||
public:
|
||||
ValueNode(const ValueType &value);
|
||||
|
||||
virtual status_t GetString(BString &predicate);
|
||||
|
||||
private:
|
||||
ValueType fValue;
|
||||
};
|
||||
|
||||
// constructor
|
||||
template<typename ValueType>
|
||||
ValueNode<ValueType>::ValueNode(const ValueType &value)
|
||||
: LeafNode(),
|
||||
fValue(value)
|
||||
{
|
||||
}
|
||||
|
||||
// GetString
|
||||
template<typename ValueType>
|
||||
status_t
|
||||
ValueNode<ValueType>::GetString(BString &predicate)
|
||||
{
|
||||
predicate.SetTo("");
|
||||
predicate << fValue;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// specializations for float and double
|
||||
template<> status_t ValueNode<float>::GetString(BString &predicate);
|
||||
template<> status_t ValueNode<double>::GetString(BString &predicate);
|
||||
|
||||
|
||||
// short hands
|
||||
typedef ValueNode<int32> Int32ValueNode;
|
||||
typedef ValueNode<uint32> UInt32ValueNode;
|
||||
typedef ValueNode<int64> Int64ValueNode;
|
||||
typedef ValueNode<uint64> UInt64ValueNode;
|
||||
typedef ValueNode<float> FloatValueNode;
|
||||
typedef ValueNode<double> DoubleValueNode;
|
||||
|
||||
|
||||
// SpecialOpNode
|
||||
class SpecialOpNode : public LeafNode {
|
||||
public:
|
||||
SpecialOpNode(query_op op);
|
||||
|
||||
virtual status_t GetString(BString &predicate);
|
||||
|
||||
private:
|
||||
query_op fOp;
|
||||
};
|
||||
|
||||
// UnaryOpNode
|
||||
class UnaryOpNode : public UnaryNode {
|
||||
public:
|
||||
UnaryOpNode(query_op op);
|
||||
|
||||
virtual status_t GetString(BString &predicate);
|
||||
|
||||
private:
|
||||
query_op fOp;
|
||||
};
|
||||
|
||||
// BinaryOpNode
|
||||
class BinaryOpNode : public BinaryNode {
|
||||
public:
|
||||
BinaryOpNode(query_op op);
|
||||
|
||||
virtual status_t GetString(BString &predicate);
|
||||
|
||||
private:
|
||||
query_op fOp;
|
||||
};
|
||||
|
||||
|
||||
// QueryStack
|
||||
class QueryStack {
|
||||
public:
|
||||
QueryStack();
|
||||
virtual ~QueryStack();
|
||||
|
||||
status_t PushNode(QueryNode *node);
|
||||
QueryNode *PopNode();
|
||||
|
||||
status_t ConvertToTree(QueryNode *&rootNode);
|
||||
|
||||
private:
|
||||
status_t _GetSubTree(QueryNode *&rootNode);
|
||||
|
||||
private:
|
||||
BList fNodes;
|
||||
};
|
||||
|
||||
}; // namespace StorageKit
|
||||
|
||||
#endif // _sk_query_predicate_h_
|
||||
@@ -0,0 +1,128 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file ResourceFile.h
|
||||
ResourceFile interface declaration.
|
||||
*/
|
||||
|
||||
#ifndef _sk_resource_file_h_
|
||||
#define _sk_resource_file_h_
|
||||
|
||||
#include <ByteOrder.h>
|
||||
|
||||
#include "OffsetFile.h"
|
||||
|
||||
struct resource_info;
|
||||
struct PEFContainerHeader;
|
||||
|
||||
namespace StorageKit {
|
||||
|
||||
class Exception;
|
||||
struct MemArea;
|
||||
class ResourceItem;
|
||||
struct resource_parse_info;
|
||||
class ResourcesContainer;
|
||||
|
||||
/*!
|
||||
\class ResourceFile
|
||||
\brief Represents a file capable of containing resources.
|
||||
|
||||
This class provides access to the resources of a file.
|
||||
Basically a ResourceFile object can be set to a file, load infos for the
|
||||
resources without loading their data (InitContainer()), read the data of
|
||||
one (ReadResource()) or all resources (ReadResources()) and write all
|
||||
resources to the file (WriteResources()).
|
||||
|
||||
Note, that the object does only provide the I/O functionality, it does
|
||||
not store any information about the resources -- this is done via a
|
||||
ResourcesContainer. We gain flexibility using this approach, since e.g.
|
||||
a certain resource may be represented by more than one ResourceItem and
|
||||
we can have as many ResourcesContainers for the resources as we like.
|
||||
In particular it is nice, that at any time we can write an arbitrary set
|
||||
of resources to the file.
|
||||
|
||||
\author <a href='mailto:[email protected]'>Ingo Weinhold</a>
|
||||
|
||||
\version 0.0.0
|
||||
*/
|
||||
class ResourceFile {
|
||||
public:
|
||||
ResourceFile();
|
||||
virtual ~ResourceFile();
|
||||
|
||||
status_t SetTo(BFile *file, bool clobber = false);
|
||||
void Unset();
|
||||
status_t InitCheck() const;
|
||||
|
||||
status_t InitContainer(ResourcesContainer &container);
|
||||
status_t ReadResource(ResourceItem &resource, bool force = false);
|
||||
status_t ReadResources(ResourcesContainer &container, bool force = false);
|
||||
status_t WriteResources(ResourcesContainer &container);
|
||||
|
||||
private:
|
||||
void _InitFile(BFile &file, bool clobber);
|
||||
void _InitELFFile(BFile &file);
|
||||
void _InitPEFFile(BFile &file, const PEFContainerHeader &pefHeader);
|
||||
void _ReadHeader(resource_parse_info &parseInfo);
|
||||
void _ReadIndex(resource_parse_info &parseInfo);
|
||||
bool _ReadIndexEntry(resource_parse_info &parseInfo, int32 index,
|
||||
uint32 tableOffset, bool peekAhead);
|
||||
void _ReadInfoTable(resource_parse_info &parseInfo);
|
||||
bool _ReadInfoTableEnd(const void *data, int32 dataSize);
|
||||
const void *_ReadResourceInfo(resource_parse_info &parseInfo,
|
||||
const MemArea &area,
|
||||
const resource_info *info, type_code type,
|
||||
bool *readIndices);
|
||||
|
||||
status_t _WriteResources(ResourcesContainer &container);
|
||||
status_t _MakeEmptyResourceFile();
|
||||
|
||||
inline int16 _GetInt16(int16 value);
|
||||
inline uint16 _GetUInt16(uint16 value);
|
||||
inline int32 _GetInt32(int32 value);
|
||||
inline uint32 _GetUInt32(uint32 value);
|
||||
|
||||
private:
|
||||
OffsetFile fFile;
|
||||
uint32 fFileType;
|
||||
bool fHostEndianess;
|
||||
bool fEmptyResources;
|
||||
};
|
||||
|
||||
// _GetInt16
|
||||
inline
|
||||
int16
|
||||
ResourceFile::_GetInt16(int16 value)
|
||||
{
|
||||
return (fHostEndianess ? value : B_SWAP_INT16(value));
|
||||
}
|
||||
|
||||
// _GetUInt16
|
||||
inline
|
||||
uint16
|
||||
ResourceFile::_GetUInt16(uint16 value)
|
||||
{
|
||||
return (fHostEndianess ? value : B_SWAP_INT16(value));
|
||||
}
|
||||
|
||||
// _GetInt32
|
||||
inline
|
||||
int32
|
||||
ResourceFile::_GetInt32(int32 value)
|
||||
{
|
||||
return (fHostEndianess ? value : B_SWAP_INT32(value));
|
||||
}
|
||||
|
||||
// _GetUInt32
|
||||
inline
|
||||
uint32
|
||||
ResourceFile::_GetUInt32(uint32 value)
|
||||
{
|
||||
return (fHostEndianess ? value : B_SWAP_INT32(value));
|
||||
}
|
||||
|
||||
}; // namespace StorageKit
|
||||
|
||||
#endif // _sk_resource_file_h_
|
||||
@@ -0,0 +1,87 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file ResourcesItem.h
|
||||
ResourceItem interface declaration.
|
||||
*/
|
||||
|
||||
#ifndef _sk_resource_item_h_
|
||||
#define _sk_resource_item_h_
|
||||
|
||||
#include <MallocIO.h>
|
||||
#include <String.h>
|
||||
|
||||
namespace StorageKit {
|
||||
|
||||
/*!
|
||||
\class ResourceItem
|
||||
\brief Represents a resource loaded into memory.
|
||||
|
||||
This class represents a resource completely or partially loaded into
|
||||
memory. The minimal information stored in the object should be its
|
||||
type, ID and name and the size of its data. If the data are not loaded
|
||||
then additionally the offset (into a resource file) should be valid.
|
||||
As soon as the data are loaded as well, the offset is more or less
|
||||
meaningless.
|
||||
|
||||
Creating a new resource can be done by calling SetIdentity() after the
|
||||
default construction. The object then represents a resource with the
|
||||
specified type, ID and name and with empty data. Data can arbitrarily
|
||||
be read and written using the methods the super class BMallocIO provides.
|
||||
|
||||
The memory for the resource data is owned by the ResourceItem object and
|
||||
freed on destruction.
|
||||
|
||||
\author <a href='mailto:[email protected]'>Ingo Weinhold</a>
|
||||
|
||||
\version 0.0.0
|
||||
*/
|
||||
class ResourceItem : public BMallocIO {
|
||||
public:
|
||||
ResourceItem();
|
||||
virtual ~ResourceItem();
|
||||
|
||||
virtual ssize_t WriteAt(off_t pos, const void *buffer, size_t size);
|
||||
virtual status_t SetSize(off_t size);
|
||||
|
||||
void SetLocation(int32 offset, size_t initialSize);
|
||||
void SetIdentity(type_code type, int32 id, const char *name);
|
||||
|
||||
void SetOffset(int32 offset);
|
||||
int32 Offset() const;
|
||||
|
||||
size_t InitialSize() const;
|
||||
size_t DataSize() const;
|
||||
|
||||
void SetType(type_code type);
|
||||
type_code Type() const;
|
||||
|
||||
void SetID(int32 id);
|
||||
int32 ID() const;
|
||||
|
||||
void SetName(const char *name);
|
||||
const char *Name() const;
|
||||
|
||||
void *Data() const;
|
||||
|
||||
void SetLoaded(bool loaded);
|
||||
bool IsLoaded() const;
|
||||
|
||||
void SetModified(bool modified);
|
||||
bool IsModified() const;
|
||||
|
||||
private:
|
||||
int32 fOffset;
|
||||
size_t fInitialSize;
|
||||
type_code fType;
|
||||
int32 fID;
|
||||
BString fName;
|
||||
bool fIsLoaded;
|
||||
bool fIsModified;
|
||||
};
|
||||
|
||||
}; // namespace StorageKit
|
||||
|
||||
#endif // _sk_resource_item_h_
|
||||
@@ -0,0 +1,75 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file ResourcesContainer.h
|
||||
ResourcesContainer interface declaration.
|
||||
*/
|
||||
|
||||
#ifndef _sk_resources_container_h_
|
||||
#define _sk_resources_container_h_
|
||||
|
||||
#include <List.h>
|
||||
|
||||
namespace StorageKit {
|
||||
|
||||
class ResourceItem;
|
||||
|
||||
/*!
|
||||
\class ResourcesContainer
|
||||
\brief Represents a collection of resources.
|
||||
|
||||
This class can be used to manage a collection of resources represented
|
||||
by ResourceItem's. Usually it does never contain two resources with the
|
||||
same type \em and ID, since AddResource() replaces an old item with the
|
||||
new one, unless explicitly told not to do so. This should only be done
|
||||
by ResourceFile, when type and ID of the items are not yet known.
|
||||
Asside from the basic vector features like Add/RemoveResource()/
|
||||
ResourceAt() and MakeEmpty() a bunch of IndexOf() methods are provided
|
||||
and AssimilateResources() which incorporates all resources of another
|
||||
container into this one (replacing old resources, if necessary), emptying
|
||||
the other one.
|
||||
|
||||
The ResourceItem's in a container are deleted on destruction, unless
|
||||
removed before via RemoveResource(). MakeEmpty() deletes the items as
|
||||
well.
|
||||
|
||||
\author <a href='mailto:[email protected]'>Ingo Weinhold</a>
|
||||
|
||||
\version 0.0.0
|
||||
*/
|
||||
class ResourcesContainer {
|
||||
public:
|
||||
ResourcesContainer();
|
||||
virtual ~ResourcesContainer();
|
||||
|
||||
bool AddResource(ResourceItem *item, int32 index = -1,
|
||||
bool replace = true);
|
||||
|
||||
ResourceItem *RemoveResource(int32 index);
|
||||
bool RemoveResource(ResourceItem *item);
|
||||
|
||||
void MakeEmpty();
|
||||
|
||||
void AssimilateResources(ResourcesContainer &container);
|
||||
|
||||
int32 IndexOf(ResourceItem *item) const;
|
||||
int32 IndexOf(const void *data) const;
|
||||
int32 IndexOf(type_code type, int32 id) const;
|
||||
int32 IndexOf(type_code type, const char *name) const;
|
||||
int32 IndexOfType(type_code type, int32 index) const;
|
||||
ResourceItem *ResourceAt(int32 index) const;
|
||||
int32 CountResources() const;
|
||||
|
||||
void SetModified(bool modified);
|
||||
bool IsModified() const;
|
||||
|
||||
private:
|
||||
BList fResources;
|
||||
bool fIsModified;
|
||||
};
|
||||
|
||||
}; // namespace StorageKit
|
||||
|
||||
#endif // _sk_resources_container_h_
|
||||
@@ -0,0 +1,105 @@
|
||||
// ResourcesDefs.h
|
||||
|
||||
#ifndef _sk_resources_defs_h_
|
||||
#define _sk_resources_defs_h_
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
// x86 resource file constants
|
||||
const char kX86ResourceFileMagic[4] = { 'R', 'S', 0, 0 };
|
||||
const uint32 kX86ResourcesOffset = 0x00000004;
|
||||
|
||||
// PPC resource file constants
|
||||
const char kPPCResourceFileMagic[4] = { 'r', 'e', 's', 'f' };
|
||||
const uint32 kPPCResourcesOffset = 0x00000028;
|
||||
|
||||
// ELF file related constants
|
||||
const uint32 kELFMinResourceAlignment = 32;
|
||||
|
||||
// the unused data pattern
|
||||
const uint32 kUnusedResourceDataPattern[3] = {
|
||||
0xffffffff, 0x000003e9, 0x00000000
|
||||
};
|
||||
|
||||
|
||||
// the resources header
|
||||
struct resources_header {
|
||||
uint32 rh_resources_magic;
|
||||
uint32 rh_resource_count;
|
||||
uint32 rh_index_section_offset;
|
||||
uint32 rh_admin_section_size;
|
||||
uint32 rh_pad[13];
|
||||
};
|
||||
|
||||
const uint32 kResourcesHeaderMagic = 0x444f1000;
|
||||
const uint32 kResourceIndexSectionOffset = 0x00000044;
|
||||
const uint32 kResourceIndexSectionAlignment = 0x00000600;
|
||||
const uint32 kResourcesHeaderSize = 68;
|
||||
|
||||
|
||||
// the header of the index section
|
||||
struct resource_index_section_header {
|
||||
uint32 rish_index_section_offset;
|
||||
uint32 rish_index_section_size;
|
||||
uint32 rish_unused_data1;
|
||||
uint32 rish_unknown_section_offset;
|
||||
uint32 rish_unknown_section_size;
|
||||
uint32 rish_unused_data2[25];
|
||||
uint32 rish_info_table_offset;
|
||||
uint32 rish_info_table_size;
|
||||
uint32 rish_unused_data3;
|
||||
};
|
||||
|
||||
const uint32 kUnknownResourceSectionSize = 0x00000168;
|
||||
const uint32 kResourceIndexSectionHeaderSize = 132;
|
||||
|
||||
|
||||
// an entry of the index table
|
||||
struct resource_index_entry {
|
||||
uint32 rie_offset;
|
||||
uint32 rie_size;
|
||||
uint32 rie_pad;
|
||||
};
|
||||
|
||||
const uint32 kResourceIndexEntrySize = 12;
|
||||
|
||||
|
||||
// a resource info
|
||||
struct resource_info {
|
||||
int32 ri_id;
|
||||
int32 ri_index;
|
||||
uint16 ri_name_size;
|
||||
char ri_name[1];
|
||||
};
|
||||
|
||||
const uint32 kMinResourceInfoSize = 10;
|
||||
|
||||
|
||||
// a resource info block
|
||||
struct resource_info_block {
|
||||
type_code rib_type;
|
||||
resource_info rib_info[1];
|
||||
};
|
||||
|
||||
const uint32 kMinResourceInfoBlockSize = 4 + kMinResourceInfoSize;
|
||||
|
||||
|
||||
// the structure separating resource info blocks
|
||||
struct resource_info_separator {
|
||||
uint32 ris_value1;
|
||||
uint32 ris_value2;
|
||||
};
|
||||
|
||||
const uint32 kResourceInfoSeparatorSize = 8;
|
||||
|
||||
|
||||
// the end of the info table
|
||||
struct resource_info_table_end {
|
||||
uint32 rite_check_sum;
|
||||
uint32 rite_terminator;
|
||||
};
|
||||
|
||||
const uint32 kResourceInfoTableEndSize = 8;
|
||||
|
||||
|
||||
#endif // _sk_resources_defs_h_
|
||||
@@ -0,0 +1,17 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file StorageDefs.Private.h
|
||||
Private Storage Kit declarations needed in public headers.
|
||||
*/
|
||||
|
||||
#ifndef __sk_def_storage_private_h__
|
||||
#define __sk_def_storage_private_h__
|
||||
|
||||
namespace StorageKit {
|
||||
typedef int FileDescriptor;
|
||||
};
|
||||
|
||||
#endif // __sk_def_storage_private_h__
|
||||
@@ -0,0 +1,326 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file kernel_interface.h
|
||||
This is the private interface used by the Storage Kit
|
||||
to communicate with the kernel
|
||||
*/
|
||||
|
||||
#ifndef _sk_kernel_interface_h_
|
||||
#define _sk_kernel_interface_h_
|
||||
|
||||
#include <SupportKit.h>
|
||||
#include <StorageDefs.Private.h>
|
||||
|
||||
// For typedefs
|
||||
#include <sys/dirent.h> // For dirent
|
||||
#include <sys/stat.h> // For struct stat
|
||||
#include <fcntl.h> // For flock
|
||||
|
||||
// Forward Declarations
|
||||
typedef struct attr_info;
|
||||
typedef struct entry_ref;
|
||||
|
||||
//! Private Storage Kit Namespace
|
||||
/*! Encompasses the functions used internally by the Storage Kit to
|
||||
interface with the kernel, as well as various internal support functions,
|
||||
data types, and type aliases. */
|
||||
namespace StorageKit {
|
||||
|
||||
// Type aliases
|
||||
typedef dirent DirEntry;
|
||||
typedef flock FileLock;
|
||||
typedef struct stat Stat;
|
||||
typedef uint32 StatMember;
|
||||
typedef attr_info AttrInfo;
|
||||
typedef int OpenFlags; // open() flags
|
||||
typedef mode_t CreationFlags; // open() mode
|
||||
typedef int SeekMode; // lseek() mode
|
||||
|
||||
// For convenience:
|
||||
struct LongDirEntry : DirEntry { char _buffer[B_FILE_NAME_LENGTH]; };
|
||||
|
||||
// Constants -- POSIX versions
|
||||
const FileDescriptor NullFd = -1;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// File Functions
|
||||
//------------------------------------------------------------------------------
|
||||
/*! \brief Opens the filesystem entry specified by path.
|
||||
|
||||
Returns a
|
||||
new file descriptor if successful, -1 otherwise. This version
|
||||
fails if the given file does not exist, or if you specify
|
||||
O_CREAT as one of the flags (use the four argument version
|
||||
of StorageKit::open() if you wish to create the file when
|
||||
it doesn't already exist). */
|
||||
status_t open(const char *path, OpenFlags flags, FileDescriptor &result);
|
||||
|
||||
/*! \brief Same as the other version of open() except the file is created with the
|
||||
permissions given by creationFlags if it doesn't exist. */
|
||||
status_t open(const char *path, OpenFlags flags, CreationFlags creationFlags,
|
||||
FileDescriptor &result);
|
||||
|
||||
/*! \brief Closes a previously open()ed file. */
|
||||
status_t close( FileDescriptor file );
|
||||
|
||||
//! Reads data from a file into a buffer.
|
||||
ssize_t read(FileDescriptor fd, void *buf, size_t len);
|
||||
|
||||
//! Reads data from a certain position in a file into a buffer.
|
||||
ssize_t read(FileDescriptor fd, void *buf, off_t pos, size_t len);
|
||||
|
||||
//! Writes data from a buffer into a file.
|
||||
ssize_t write(FileDescriptor fd, const void *buf, size_t len);
|
||||
|
||||
//! Writes data from a buffer to a certain position in a file.
|
||||
ssize_t write(FileDescriptor fd, const void *buf, off_t pos, size_t len);
|
||||
|
||||
//! Moves a file's read/write pointer.
|
||||
off_t seek(FileDescriptor fd, off_t pos, SeekMode mode);
|
||||
|
||||
//! Returns the position of a file's read/write pointer.
|
||||
off_t get_position(FileDescriptor fd);
|
||||
|
||||
/*! \brief Returns a new file descriptor that refers to the same file as
|
||||
that specified, or -1 if unsuccessful. Remember to call close
|
||||
on the file descriptor when through with it. */
|
||||
FileDescriptor dup(FileDescriptor file);
|
||||
|
||||
/*! \brief Similar to the first version, aside from that an error code is
|
||||
returned and the resulting file descriptor is passed back via a reference
|
||||
parameter. */
|
||||
status_t dup(FileDescriptor file, FileDescriptor& result);
|
||||
|
||||
/*! \brief Flushes any buffers associated with the given file to disk
|
||||
and then returns. */
|
||||
status_t sync(FileDescriptor file);
|
||||
|
||||
//! Locks the given file so it may not be accessed by anyone else.
|
||||
status_t lock(FileDescriptor file, OpenFlags mode, FileLock *lock);
|
||||
|
||||
//! Unlocks a file previously locked with lock().
|
||||
status_t unlock(FileDescriptor file, FileLock *lock);
|
||||
|
||||
//! Returns statistical information for the given file.
|
||||
status_t get_stat(const char *path, Stat *s);
|
||||
status_t get_stat(FileDescriptor file, Stat *s);
|
||||
status_t get_stat(entry_ref &ref, Stat *s);
|
||||
|
||||
//! Modifies a given portion of the file's statistical information.
|
||||
status_t set_stat(FileDescriptor file, Stat &s, StatMember what);
|
||||
|
||||
//! Same as the other version of set_stat(), except the file is specified by name.
|
||||
status_t set_stat(const char *filename, Stat &s, StatMember what);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Attribute Functions
|
||||
//------------------------------------------------------------------------------
|
||||
/*! \brief Reads the data from the specified attribute into the given buffer of size
|
||||
count. Returns the number of bytes actually read. */
|
||||
ssize_t read_attr(FileDescriptor file, const char *attribute, uint32 type,
|
||||
off_t pos, void *buf, size_t count );
|
||||
|
||||
//! Write count bytes from the given data buffer into the specified attribute.
|
||||
ssize_t write_attr(FileDescriptor file, const char *attribute, uint32 type,
|
||||
off_t pos, const void *buf, size_t count);
|
||||
|
||||
//! Renames the specified attribute.
|
||||
status_t rename_attr(FileDescriptor file, const char *oldName,
|
||||
const char *newName);
|
||||
|
||||
//! Removes the specified attribute and any data associated with it.
|
||||
status_t remove_attr(FileDescriptor file, const char *attr);
|
||||
|
||||
//! Returns statistical information about the given attribute. */
|
||||
status_t stat_attr(FileDescriptor file, const char *name, AttrInfo *ai);
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Attribute Directory Functions
|
||||
//------------------------------------------------------------------------------
|
||||
/*! Opens the attribute directory of a given file. */
|
||||
status_t open_attr_dir(FileDescriptor file, FileDescriptor &result);
|
||||
|
||||
/*! Rewinds the given attribute directory. */
|
||||
status_t rewind_attr_dir(FileDescriptor dir);
|
||||
|
||||
/*! Returns the next item in the given attribute directory, or
|
||||
B_ENTRY_NOT_FOUND if at the end of the list. */
|
||||
status_t read_attr_dir(FileDescriptor dir, DirEntry &buffer);
|
||||
|
||||
/*! Closes an attribute directory previously opened with open_attr_dir(). */
|
||||
status_t close_attr_dir(FileDescriptor dir);
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Directory Functions
|
||||
//------------------------------------------------------------------------------
|
||||
/*! \brief Opens the given directory. Sets result to a properly "unitialized" directory
|
||||
if the function fails. */
|
||||
status_t open_dir(const char *path, FileDescriptor &result);
|
||||
|
||||
//! Creates a new directory.
|
||||
status_t create_dir(const char *path,
|
||||
mode_t mode = S_IRWXU | S_IRWXG | S_IRWXU);
|
||||
|
||||
//! Creates a new directory and opens it.
|
||||
status_t create_dir(const char *path, FileDescriptor &result,
|
||||
mode_t mode = S_IRWXU | S_IRWXG | S_IRWXU);
|
||||
|
||||
//! Returns the next entries in the given directory.
|
||||
int32 read_dir(FileDescriptor dir, DirEntry *buffer, size_t length,
|
||||
int32 count = INT_MAX);
|
||||
|
||||
/*! Rewindes the directory to the first entry in the list. */
|
||||
status_t rewind_dir(FileDescriptor dir);
|
||||
|
||||
/*! Iterates through the given directory searching for an entry whose name
|
||||
matches that given by name. On success, places the DirEntry in result
|
||||
and returns B_OK. On failures, returns an error code and sets result to
|
||||
StorageKit::NullDir.
|
||||
|
||||
<b>Note:</b> This call modifies the internal position marker of dir. */
|
||||
status_t find_dir(FileDescriptor dir, const char *name, DirEntry *result,
|
||||
size_t length);
|
||||
|
||||
/*! Calls the other version of StorageKit::find_dir() and stores the results
|
||||
in the given entry_ref. */
|
||||
status_t find_dir(FileDescriptor dir, const char *name, entry_ref *result);
|
||||
|
||||
/*! Creates a duplicated of the given directory and places it in result if successful,
|
||||
returning B_OK. Returns an error code and sets result to -1 if
|
||||
unsuccessful. */
|
||||
status_t dup_dir(FileDescriptor dir, FileDescriptor &result);
|
||||
|
||||
/*! Closes the given directory. */
|
||||
status_t close_dir(FileDescriptor dir);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// SymLink functions
|
||||
//------------------------------------------------------------------------------
|
||||
//! Creates a new symbolic link.
|
||||
status_t create_link(const char *path, const char *linkToPath);
|
||||
|
||||
//! Creates a new symbolic link and opens it.
|
||||
status_t create_link(const char *path, const char *linkToPath,
|
||||
FileDescriptor &result);
|
||||
|
||||
/*! If path refers to a symlink, the pathname of the target to which path
|
||||
is linked is copied into result and NULL terminated, if the buffer is
|
||||
long enough, the path is being truncated at size chars if necessary
|
||||
(a buffer of size B_PATH_NAME_LENGTH+1 is a good idea), and the number of
|
||||
chars in the target pathname is returned. If size is less than 1 or result
|
||||
is NULL, B_BAD_VALUE will be returned and result will remain unmodified.
|
||||
For any other error, result is set to an empty string and an error code
|
||||
is returned. */
|
||||
ssize_t read_link(const char *path, char *result, size_t size);
|
||||
|
||||
/*! Similar to the first version. Instead of a path name, a file descriptor
|
||||
of the symbolic link is supplied.
|
||||
*/
|
||||
ssize_t read_link(FileDescriptor fd, char *result, size_t size);
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Query Functions
|
||||
//------------------------------------------------------------------------------
|
||||
/*! \brief Opens a query. Sets result to a properly "unitialized" query
|
||||
if the function fails. */
|
||||
status_t open_query(dev_t device, const char *query, uint32 flags,
|
||||
FileDescriptor &result);
|
||||
|
||||
/*! \brief Opens a live query. Sets result to a properly "unitialized" query
|
||||
if the function fails. */
|
||||
status_t open_live_query(dev_t device, const char *query, uint32 flags,
|
||||
port_id port, int32 token, FileDescriptor &result);
|
||||
|
||||
//! Returns the next entries in the given query.
|
||||
int32 read_query(FileDescriptor query, DirEntry *buffer, size_t length,
|
||||
int32 count = INT_MAX);
|
||||
|
||||
/*! Closes the given query. */
|
||||
status_t close_query(FileDescriptor dir);
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Miscellaneous Functions
|
||||
//------------------------------------------------------------------------------
|
||||
/*! Converts the given entry_ref into an absolute pathname, returning
|
||||
the result in the string of length size pointed to by result (a size
|
||||
of B_PATH_NAME_LENGTH+1 is a good idea).
|
||||
|
||||
Returns B_OK if successful.
|
||||
|
||||
If ref or result is NULL, B_BAD_VALUE is returned. Otherwise,
|
||||
an error code is returned. The state of result after an error is undefined.
|
||||
*/
|
||||
status_t entry_ref_to_path(const struct entry_ref *ref, char *result,
|
||||
size_t size);
|
||||
|
||||
/*! See the other definition of entry_ref_to_path() */
|
||||
status_t entry_ref_to_path(dev_t device, ino_t directory, const char *name,
|
||||
char *result, size_t size);
|
||||
|
||||
/*! Converts the given directory into an entry_ref. Note that the entry_ref is
|
||||
actually a reference to the file "." in the given directory.
|
||||
|
||||
Returns B_OK if successful.
|
||||
|
||||
If dir is < 0 or result is NULL, B_BAD_VALUE is returned.
|
||||
Otherwise, an appropriate error code is returned.
|
||||
*/
|
||||
status_t dir_to_self_entry_ref(FileDescriptor dir, entry_ref *result);
|
||||
|
||||
|
||||
/*! Converts the given directory into an absolute pathname, returning the
|
||||
result in the string of length size pointed to by result (a size of
|
||||
B_PATH_NAME_LENGTH+1 is a good idea).
|
||||
|
||||
Returns B_OK if successful.
|
||||
|
||||
If dir is < 0 or result is NULL, B_BAD_VALUE
|
||||
is returned. Otherwise, an error code is returned. The state of result after
|
||||
an error is undefined.
|
||||
*/
|
||||
status_t dir_to_path( FileDescriptor dir, char *result, size_t size );
|
||||
|
||||
/*! \brief Returns the canonical representation of a given path referring to an
|
||||
potentially abstract entry in an existing directory. */
|
||||
status_t get_canonical_path(const char *path, char *result, size_t size);
|
||||
|
||||
/*! \brief Returns the canonical representation of a given path referring to an
|
||||
potentially abstract entry in an existing directory. */
|
||||
status_t get_canonical_path(const char *path, char *&result);
|
||||
|
||||
/*! \brief Returns the canonical representation of a given path referring to an
|
||||
existing directory. */
|
||||
status_t get_canonical_dir_path(const char *path, char *result, size_t size);
|
||||
|
||||
/*! \brief Returns the canonical representation of a given path referring to an
|
||||
existing directory. */
|
||||
status_t get_canonical_dir_path(const char *path, char *&result);
|
||||
|
||||
/*! \brief Returns the path of this application.
|
||||
The supplied buffer must be at least B_PATH_NAME_LENGTH + 1 bytes long.
|
||||
The result will be null terminated.
|
||||
*/
|
||||
status_t get_app_path(char *buffer);
|
||||
|
||||
/*! Returns true if the given entry_ref represents the root directory, false otherwise. */
|
||||
bool entry_ref_is_root_dir(entry_ref &ref);
|
||||
|
||||
/*! Renames oldPath to newPath, replacing newPath if it exists. */
|
||||
status_t rename(const char *oldPath, const char *newPath);
|
||||
|
||||
/*! Removes path from the filesystem. */
|
||||
status_t remove(const char *path);
|
||||
|
||||
|
||||
} // namespace StorageKit
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,42 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file storage_support.h
|
||||
Interface declarations for miscellaneous internal
|
||||
Storage Kit support functions.
|
||||
*/
|
||||
|
||||
#ifndef _sk_storage_support_h_
|
||||
#define _sk_storage_support_h_
|
||||
|
||||
|
||||
namespace StorageKit {
|
||||
|
||||
//! Returns whether the supplied path is absolute.
|
||||
bool is_absolute_path(const char *path);
|
||||
|
||||
//! splits a path name into directory path and leaf name
|
||||
status_t split_path(const char *fullPath, char *&path, char *&leaf);
|
||||
|
||||
//! splits a path name into directory path and leaf name
|
||||
status_t split_path(const char *fullPath, char **path, char **leaf);
|
||||
|
||||
//! Parses the first component of a path name.
|
||||
status_t parse_first_path_component(const char *path, int32& length,
|
||||
int32& nextComponent);
|
||||
|
||||
//! Parses the first component of a path name.
|
||||
status_t parse_first_path_component(const char *path, char *&component,
|
||||
int32& nextComponent);
|
||||
|
||||
//! Checks whether an entry name is a valid entry name.
|
||||
status_t check_entry_name(const char *entry);
|
||||
|
||||
//! Checks whether a path name is a valid path name.
|
||||
status_t check_path_name(const char *path);
|
||||
|
||||
} // namespace StorageKit
|
||||
|
||||
#endif // _sk_storage_support_h_
|
||||
Reference in New Issue
Block a user