* Style cleanup.

* Removed AutoDeleter class and use the shared one instead.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34244 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2009-11-25 15:00:40 +00:00
parent 4d89dfc712
commit ff4d0f1c92
2 changed files with 299 additions and 318 deletions
+67 -59
View File
@@ -1,41 +1,47 @@
//---------------------------------------------------------------------- /*
// This software is part of the OpenBeOS distribution and is covered * Copyright 2002-2009, Ingo Weinhold, [email protected].
// by the OpenBeOS license. * Distributed under the terms of the MIT License.
//--------------------------------------------------------------------- */
#ifndef _RESOURCE_FILE_H
#define _RESOURCE_FILE_H
/*! /*!
\file ResourceFile.h \file ResourceFile.h
ResourceFile interface declaration. ResourceFile interface declaration.
*/ */
#ifndef _RESOURCE_FILE_H
#define _RESOURCE_FILE_H
#include <ByteOrder.h> #include <ByteOrder.h>
#include "OffsetFile.h" #include "OffsetFile.h"
struct resource_info; struct resource_info;
struct PEFContainerHeader; struct PEFContainerHeader;
namespace BPrivate { namespace BPrivate {
namespace Storage { namespace Storage {
class Exception; class Exception;
struct MemArea; struct MemArea;
class ResourceItem; class ResourceItem;
struct resource_parse_info; struct resource_parse_info;
class ResourcesContainer; class ResourcesContainer;
/*! /*!
\class ResourceFile \class ResourceFile
\brief Represents a file capable of containing resources. \brief Represents a file capable of containing resources.
This class provides access to the resources of a file. This class provides access to the resources of a file.
Basically a ResourceFile object can be set to a file, load infos for the Basically a ResourceFile object can be set to a file, load infos for the
resources without loading their data (InitContainer()), read the data of resources without loading their data (InitContainer()), read the data of
one (ReadResource()) or all resources (ReadResources()) and write all one (ReadResource()) or all resources (ReadResources()) and write all
resources to the file (WriteResources()). resources to the file (WriteResources()).
Note, that the object does only provide the I/O functionality, it does 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 not store any information about the resources -- this is done via a
ResourcesContainer. We gain flexibility using this approach, since e.g. ResourcesContainer. We gain flexibility using this approach, since e.g.
@@ -45,88 +51,90 @@ class ResourcesContainer;
of resources to the file. of resources to the file.
\author <a href='mailto:[email protected]'>Ingo Weinhold</a> \author <a href='mailto:[email protected]'>Ingo Weinhold</a>
\version 0.0.0 \version 0.0.0
*/ */
class ResourceFile { class ResourceFile {
public: public:
ResourceFile(); ResourceFile();
virtual ~ResourceFile(); virtual ~ResourceFile();
status_t SetTo(BFile *file, bool clobber = false); status_t SetTo(BFile* file, bool clobber = false);
void Unset(); void Unset();
status_t InitCheck() const; status_t InitCheck() const;
status_t InitContainer(ResourcesContainer &container); status_t InitContainer(ResourcesContainer& container);
status_t ReadResource(ResourceItem &resource, bool force = false); status_t ReadResource(ResourceItem& resource,
status_t ReadResources(ResourcesContainer &container, bool force = false); bool force = false);
status_t WriteResources(ResourcesContainer &container); status_t ReadResources(ResourcesContainer& container,
bool force = false);
status_t WriteResources(ResourcesContainer& container);
private: private:
void _InitFile(BFile &file, bool clobber); void _InitFile(BFile& file, bool clobber);
void _InitELFFile(BFile &file); void _InitELFFile(BFile& file);
void _InitPEFFile(BFile &file, const PEFContainerHeader &pefHeader); void _InitPEFFile(BFile& file,
void _ReadHeader(resource_parse_info &parseInfo); const PEFContainerHeader& pefHeader);
void _ReadIndex(resource_parse_info &parseInfo); void _ReadHeader(resource_parse_info& parseInfo);
bool _ReadIndexEntry(resource_parse_info &parseInfo, int32 index, void _ReadIndex(resource_parse_info& parseInfo);
uint32 tableOffset, bool peekAhead); bool _ReadIndexEntry(resource_parse_info& parseInfo,
void _ReadInfoTable(resource_parse_info &parseInfo); int32 index, uint32 tableOffset,
bool _ReadInfoTableEnd(const void *data, int32 dataSize); bool peekAhead);
const void *_ReadResourceInfo(resource_parse_info &parseInfo, void _ReadInfoTable(resource_parse_info& parseInfo);
const MemArea &area, bool _ReadInfoTableEnd(const void* data,
const resource_info *info, type_code type, int32 dataSize);
bool *readIndices); 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 _WriteResources(ResourcesContainer& container);
status_t _MakeEmptyResourceFile(); status_t _MakeEmptyResourceFile();
inline int16 _GetInt16(int16 value); inline int16 _GetInt16(int16 value);
inline uint16 _GetUInt16(uint16 value); inline uint16 _GetUInt16(uint16 value);
inline int32 _GetInt32(int32 value); inline int32 _GetInt32(int32 value);
inline uint32 _GetUInt32(uint32 value); inline uint32 _GetUInt32(uint32 value);
private: private:
OffsetFile fFile; OffsetFile fFile;
uint32 fFileType; uint32 fFileType;
bool fHostEndianess; bool fHostEndianess;
bool fEmptyResources; bool fEmptyResources;
}; };
// _GetInt16
inline inline int16
int16
ResourceFile::_GetInt16(int16 value) ResourceFile::_GetInt16(int16 value)
{ {
return (fHostEndianess ? value : B_SWAP_INT16(value)); return fHostEndianess ? value : B_SWAP_INT16(value);
} }
// _GetUInt16
inline inline uint16
uint16
ResourceFile::_GetUInt16(uint16 value) ResourceFile::_GetUInt16(uint16 value)
{ {
return (fHostEndianess ? value : B_SWAP_INT16(value)); return fHostEndianess ? value : B_SWAP_INT16(value);
} }
// _GetInt32
inline inline int32
int32
ResourceFile::_GetInt32(int32 value) ResourceFile::_GetInt32(int32 value)
{ {
return (fHostEndianess ? value : B_SWAP_INT32(value)); return fHostEndianess ? value : B_SWAP_INT32(value);
} }
// _GetUInt32
inline inline uint32
uint32
ResourceFile::_GetUInt32(uint32 value) ResourceFile::_GetUInt32(uint32 value)
{ {
return (fHostEndianess ? value : B_SWAP_INT32(value)); return fHostEndianess ? value : B_SWAP_INT32(value);
} }
}; // namespace Storage }; // namespace Storage
}; // namespace BPrivate }; // namespace BPrivate
#endif // _RESOURCE_FILE_H #endif // _RESOURCE_FILE_H
File diff suppressed because it is too large Load Diff