1 /* 2 * Copyright 2001-2013, Haiku Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _RESOURCES_H 6 #define _RESOURCES_H 7 8 9 #include <Entry.h> 10 #include <File.h> 11 #include <image.h> 12 13 14 namespace BPrivate { 15 namespace Storage { 16 class ResourcesContainer; 17 class ResourceFile; 18 }; 19 }; 20 21 22 class BResources { 23 public: 24 BResources(); 25 BResources(const BFile* file, 26 bool clobber = false); 27 // Haiku only 28 BResources(const char* path, 29 bool clobber = false); 30 // Haiku only 31 BResources(const entry_ref* ref, 32 bool clobber = false); 33 34 virtual ~BResources(); 35 36 status_t SetTo(const BFile* file, 37 bool clobber = false); 38 // Haiku only 39 status_t SetTo(const char* path, 40 bool clobber = false); 41 // Haiku only 42 status_t SetTo(const entry_ref* ref, 43 bool clobber = false); 44 45 // Haiku only 46 status_t SetToImage(image_id image, 47 bool clobber = false); 48 status_t SetToImage(const void* codeOrDataPointer, 49 bool clobber = false); 50 51 void Unset(); 52 status_t InitCheck() const; 53 54 const BFile &File() const; 55 56 const void* LoadResource(type_code type, int32 id, 57 size_t* _size); 58 const void* LoadResource(type_code type, const char* name, 59 size_t* _size); 60 61 status_t PreloadResourceType(type_code type = 0); 62 63 status_t Sync(); 64 status_t MergeFrom(BFile* fromFile); 65 status_t WriteTo(BFile* file); 66 67 status_t AddResource(type_code type, int32 id, 68 const void* data, size_t length, 69 const char* name = NULL); 70 71 bool HasResource(type_code type, int32 id); 72 bool HasResource(type_code type, const char* name); 73 74 bool GetResourceInfo(int32 byIndex, 75 type_code* typeFound, int32* idFound, 76 const char** nameFound, 77 size_t* lengthFound); 78 bool GetResourceInfo(type_code byType, 79 int32 andIndex, int32* idFound, 80 const char** nameFound, 81 size_t* lengthFound); 82 bool GetResourceInfo(type_code byType, int32 andID, 83 const char **nameFound, 84 size_t* lengthFound); 85 bool GetResourceInfo(type_code byType, 86 const char* andName, int32* idFound, 87 size_t* lengthFound); 88 bool GetResourceInfo(const void* byPointer, 89 type_code* typeFound, 90 int32* idFound, size_t* lengthFound, 91 const char** nameFound); 92 93 status_t RemoveResource(const void *resource); 94 status_t RemoveResource(type_code type, int32 id); 95 96 // deprecated 97 status_t WriteResource(type_code type, int32 id, 98 const void* data, off_t offset, 99 size_t length); 100 101 status_t ReadResource(type_code type, int32 id, 102 void* data, off_t offset, 103 size_t length); 104 105 void* FindResource(type_code type, int32 id, 106 size_t* lengthFound); 107 void* FindResource(type_code type, const char* name, 108 size_t *lengthFound); 109 110 private: 111 // FBC 112 virtual void _ReservedResources1(); 113 virtual void _ReservedResources2(); 114 virtual void _ReservedResources3(); 115 virtual void _ReservedResources4(); 116 virtual void _ReservedResources5(); 117 virtual void _ReservedResources6(); 118 virtual void _ReservedResources7(); 119 virtual void _ReservedResources8(); 120 121 private: 122 BFile fFile; 123 BPrivate::Storage::ResourcesContainer* fContainer; 124 BPrivate::Storage::ResourceFile* fResourceFile; 125 bool fReadOnly; 126 bool _pad[3]; 127 // FBC 128 uint32 _reserved[3]; 129 }; 130 131 132 #endif // _RESOURCES_H 133