5 #include "OffsetFile.h"
8 OffsetFile::OffsetFile()
16 OffsetFile::OffsetFile(const BFile
& file
, off_t offset
)
25 OffsetFile::~OffsetFile()
31 OffsetFile::SetTo(const BFile
& file
, off_t offset
)
36 return fFile
.InitCheck();
50 OffsetFile::InitCheck() const
52 return fFile
.InitCheck();
57 //OffsetFile::Read(void *buffer, size_t size)
59 // return fFile.Read(buffer, size);
64 //OffsetFile::Write(const void *buffer, size_t size)
66 // return fFile.Write(buffer, size);
71 OffsetFile::ReadAt(off_t pos
, void *buffer
, size_t size
)
73 //printf("ReadAt(%Lx + %Lx, %lu)\n", pos, fOffset, size);
74 return fFile
.ReadAt(pos
+ fOffset
, buffer
, size
);
79 OffsetFile::WriteAt(off_t pos
, const void *buffer
, size_t size
)
81 return fFile
.WriteAt(pos
+ fOffset
, buffer
, size
);
86 OffsetFile::Seek(off_t position
, uint32 seekMode
)
88 // off_t result = fFile.Seek(position + fOffset, seekMode);
92 off_t result
= B_BAD_VALUE
;
96 result
= fCurrentPosition
= position
;
101 status_t error
= GetSize(&size
);
102 if (size
+ position
>= 0)
103 result
= fCurrentPosition
= size
+ position
;
109 if (fCurrentPosition
+ position
>= 0)
110 result
= fCurrentPosition
+= position
;
120 OffsetFile::Position() const
122 // off_t result = fFile.Position();
124 // result -= fOffset;
126 return fCurrentPosition
;
131 OffsetFile::SetSize(off_t size
)
133 status_t error
= (size
>= 0 ? B_OK
: B_BAD_VALUE
);
135 error
= fFile
.SetSize(size
+ fOffset
);
141 OffsetFile::GetSize(off_t
* size
)
143 status_t error
= fFile
.GetSize(size
);
151 OffsetFile::GetOffset() const