btrfs: [] on the end of a struct field is a variable length array.
[haiku.git] / headers / private / storage / OffsetFile.h
blob221e1438862ec2e477d353c6d3f0a119ee1e0abd
1 //----------------------------------------------------------------------
2 // This software is part of the OpenBeOS distribution and is covered
3 // by the MIT License.
4 //---------------------------------------------------------------------
5 /*!
6 \file OffsetFile.h
7 OffsetFile interface declaration.
8 */
10 #ifndef _OFFSET_FILE_H
11 #define _OFFSET_FILE_H
13 #include <DataIO.h>
14 #include <File.h>
16 namespace BPrivate {
17 namespace Storage {
19 /*!
20 \class OffsetFile
21 \brief Provides access to a file skipping a certain amount of bytes at
22 the beginning.
24 This class implements the BPositionIO interface to provide access to the
25 data of a file past a certain offset. This is very handy e.g. for dealing
26 with resources, as they always reside at the end of a file, but may start
27 at arbitrary offsets.
29 \author <a href='mailto:bonefish@users.sf.net'>Ingo Weinhold</a>
31 \version 0.0.0
33 class OffsetFile : public BPositionIO {
34 public:
35 OffsetFile();
36 OffsetFile(BFile *file, off_t offset);
37 virtual ~OffsetFile();
39 status_t SetTo(BFile *file, off_t offset);
40 void Unset();
41 status_t InitCheck() const;
43 BFile *File() const;
45 ssize_t ReadAt(off_t pos, void *buffer, size_t size);
46 ssize_t WriteAt(off_t pos, const void *buffer,
47 size_t size);
48 off_t Seek(off_t position, uint32 seekMode);
49 off_t Position() const;
51 status_t SetSize(off_t size);
52 status_t GetSize(off_t *size) const;
54 off_t Offset() const;
56 private:
57 BFile* fFile;
58 off_t fOffset;
59 off_t fCurrentPosition;
62 }; // namespace Storage
63 }; // namespace BPrivate
65 #endif // _OFFSET_FILE_H