vfs: check userland buffers before reading them.
[haiku.git] / src / apps / mediaplayer / support / FileReadWrite.h
blob4c2e89dd646ba3325c38d7aa7fdc837a09da0997
1 /*
2 * Copyright 2008, Haiku. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Michael Pfeiffer <laplace@users.sourceforge.net>
7 * Fredrik Modéen <fredrik@modeen.se>
8 */
9 #ifndef FILE_READ_WRITE_H
10 #define FILE_READ_WRITE_H
12 #include <stdio.h>
13 #include <File.h>
14 #include <String.h>
17 class FileReadWrite {
18 public:
19 FileReadWrite(BFile* file,
20 int32 sourceEncoding = -1);
21 // -1 means "default" encoding
22 bool Next(BString& string);
23 status_t Write(const BString& contents) const;
24 void SetEncoding(int32 sourceEncoding);
25 uint32 GetEncoding() const;
27 private:
28 BFile* fFile;
29 int32 fSourceEncoding;
30 char fBuffer[4096];
31 off_t fPositionInBuffer;
32 ssize_t fAmtRead;
35 #endif //FILE_READ_WRITE_H