1 /* 2 * Copyright 2008, Haiku. 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 10 #ifndef _FILEREADRWITE_ 11 #define _FILEREADRWITE_ 12 13 #include <stdio.h> 14 #include <File.h> 15 #include <String.h> 16 17 class FileReadWrite { 18 public: 19 // -1 defult encoding 20 FileReadWrite(BFile *file, int32 sourceEncoding = -1); 21 bool Next(BString& string); 22 status_t Write(const BString& contents)const; 23 void SetEncoding(int32 sourceEncoding); 24 uint32 GetEncoding(); 25 26 private: 27 BFile* fFile; 28 int32 fSourceEncoding; 29 char fBuffer[4096]; 30 off_t fPositionInBuffer; 31 ssize_t fAmtRead; 32 }; 33 34 #endif //_FILEREADRWITE_ 35