fileObject.h

Engine/source/core/fileObject.h

More...

Classes:

Detailed Description

 1
 2//-----------------------------------------------------------------------------
 3// Copyright (c) 2012 GarageGames, LLC
 4//
 5// Permission is hereby granted, free of charge, to any person obtaining a copy
 6// of this software and associated documentation files (the "Software"), to
 7// deal in the Software without restriction, including without limitation the
 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 9// sell copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21// IN THE SOFTWARE.
22//-----------------------------------------------------------------------------
23
24#ifndef _FILEOBJECT_H_
25#define _FILEOBJECT_H_
26
27#ifndef _SIMBASE_H_
28#include "console/simBase.h"
29#endif
30#ifndef _FILESTREAM_H_
31#include "core/stream/fileStream.h"
32#endif
33
34class FileObject : public SimObject
35{
36   typedef SimObject Parent;
37   U8 *mFileBuffer;
38   U32 mBufferSize;
39   U32 mCurPos;
40   FileStream *stream;
41public:
42   FileObject();
43   ~FileObject();
44
45   bool openForWrite(const char *fileName, const bool append = false);
46   bool openForRead(const char *fileName);
47   bool readMemory(const char *fileName);
48   const U8 *buffer() { return mFileBuffer; }
49   const U8 *readLine();
50   void peekLine(U8 *line, S32 length);
51   bool isEOF();
52   void writeLine(const U8 *line);
53   void close();
54   void writeObject( SimObject* object, const U8* objectPrepend = NULL );
55
56   DECLARE_CONOBJECT(FileObject);
57};
58
59#endif
60