xref: /haiku/src/apps/mediaplayer/support/FileReadWrite.h (revision 21258e2674226d6aa732321b6f8494841895af5f)
1 /*
2  * Copyright 2008, Haiku. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
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
11 
12 #include <stdio.h>
13 #include <File.h>
14 #include <String.h>
15 
16 
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;
26 
27 private:
28 			BFile*				fFile;
29 			int32				fSourceEncoding;
30 			char				fBuffer[4096];
31 			off_t				fPositionInBuffer;
32 			ssize_t				fAmtRead;
33 };
34 
35 #endif //FILE_READ_WRITE_H
36