1 //----------------------------------------------------------------------
2 // This software is part of the OpenBeOS distribution and is covered
4 //---------------------------------------------------------------------
6 \file ResourcesItem.cpp
7 ResourceItem implementation.
10 #include "ResourceItem.h"
21 ResourceItem::ResourceItem()
35 ResourceItem::~ResourceItem()
41 ResourceItem::WriteAt(off_t pos
, const void *buffer
, size_t size
)
43 ssize_t result
= BMallocIO::WriteAt(pos
, buffer
, size
);
51 ResourceItem::SetSize(off_t size
)
53 status_t error
= BMallocIO::SetSize(size
);
61 ResourceItem::SetLocation(int32 offset
, size_t initialSize
)
64 fInitialSize
= initialSize
;
69 ResourceItem::SetIdentity(type_code type
, int32 id
, const char *name
)
78 ResourceItem::SetOffset(int32 offset
)
85 ResourceItem::Offset() const
92 ResourceItem::InitialSize() const
99 ResourceItem::DataSize() const
102 return BufferLength();
108 ResourceItem::SetType(type_code type
)
115 ResourceItem::Type() const
122 ResourceItem::SetID(int32 id
)
129 ResourceItem::ID() const
136 ResourceItem::SetName(const char *name
)
143 ResourceItem::Name() const
145 return fName
.String();
150 ResourceItem::Data() const
152 // Since MallocIO may have a NULL buffer, if the data size is 0,
153 // we return a pointer to ourselves in this case. This ensures, that
154 // the resource item still can be uniquely identified by its data pointer.
156 return const_cast<ResourceItem
*>(this);
157 return const_cast<void*>(Buffer());
162 ResourceItem::SetLoaded(bool loaded
)
169 ResourceItem::IsLoaded() const
171 return (BufferLength() > 0 || fIsLoaded
);
176 ResourceItem::SetModified(bool modified
)
178 fIsModified
= modified
;
183 ResourceItem::IsModified() const
189 }; // namespace Storage
190 }; // namespace BPrivate