00001 /** 00002 * @file Platform/Aperios1.3.2/File.h 00003 * 00004 * Declaration of class File for Aperios 1.3.2. 00005 */ 00006 00007 #ifndef __File_h__ 00008 #define __File_h__ 00009 00010 #ifdef __GNUC__ 00011 #include <stdio.h> 00012 #define OFS 00013 #else 00014 #include <FileSystem/futil.h> 00015 #endif 00016 00017 /** 00018 * This class provides basic file input/output capabilies. 00019 */ 00020 class File 00021 { 00022 private: 00023 OFS::FILE* stream; /**< File handle. */ 00024 char buf[65536]; /**< A buffer to reduce the number of operation system calls. */ 00025 unsigned int bufSize, /**< The number of bytes in the buffer while reading. */ 00026 index; /**< The next byte in the buffer to read/write. */ 00027 bool isWrite; /**< Is this a write stream? */ 00028 public: 00029 /** 00030 * Constructor. 00031 * @param name File name or path. If it is a relative path, it is assumed 00032 * to be relative to the path for configuration files. Otherwise, 00033 * the path is used directly. 00034 * @param mode File open mode as used by fopen defined in stdio.h. 00035 */ 00036 File(const char* name,const char* mode); 00037 00038 /** 00039 * Destructor. 00040 */ 00041 ~File(); 00042 00043 /** 00044 * The function read a number of bytes from the file to a certain 00045 * memory location. 00046 * @param p The start of the memory space the data is written to. 00047 * @param size The number of bytes read from the file. 00048 */ 00049 void read(void* p,unsigned size); 00050 00051 /** 00052 * The function writes a number of bytes from a certain memory 00053 * location into the file. 00054 * @param p The start of the memory space the data is read from. 00055 * @param size The number of bytes written into the file. 00056 */ 00057 void write(const void *p,unsigned size); 00058 00059 /** 00060 * The function implements printf for the stream represented by 00061 * instances of this class. 00062 * @param format Format string as used by printf defined in stdio.h. 00063 * @param ... See printf in stdio.h. 00064 */ 00065 void printf(const char* format, ...); 00066 00067 /** 00068 * The function returns whether the file represented by an 00069 * object of this class actually exists. 00070 * @return The existence of the file. 00071 */ 00072 bool exists() const {return stream != 0;} 00073 00074 /** 00075 * The function returns whether the end of the file represented 00076 * by an object of this class was reached. 00077 * @return End of file reached? 00078 */ 00079 bool eof() const; 00080 00081 /** 00082 * The function returns the current GT directory, 00083 * e.g. /MS/OPENR/APP or <...>/GT2003 or /usr/local/GT2003 00084 * @return The current GTDir 00085 */ 00086 static char* getGTDir(); 00087 }; 00088 00089 #endif // __FILE_H__ 00090 00091 /* 00092 * Change log : 00093 * 00094 * $Log: File.h,v $ 00095 * Revision 1.1.1.1 2004/05/22 17:23:25 cvsadm 00096 * created new repository GT2004_WM 00097 * 00098 * Revision 1.3 2004/01/22 12:42:25 dueffert 00099 * flush removed because it doesnt work properly on robots 00100 * 00101 * Revision 1.2 2004/01/16 15:46:27 dueffert 00102 * flush added to File and OutFile 00103 * 00104 * Revision 1.1 2003/10/07 10:06:59 cvsadm 00105 * Created GT2004 (M.J.) 00106 * 00107 * Revision 1.2 2003/09/26 11:36:26 juengel 00108 * - sorted tools 00109 * - clean-up in DataTypes 00110 * 00111 * Revision 1.1.1.1 2003/07/02 09:40:24 cvsadm 00112 * created new repository for the competitions in Padova from the 00113 * tamara CVS (Tuesday 2:00 pm) 00114 * 00115 * removed unused solutions 00116 * 00117 * Revision 1.3 2003/03/11 09:02:12 dueffert 00118 * signed comparison warning removed 00119 * 00120 * Revision 1.2 2002/11/18 17:32:35 dueffert 00121 * RobotControl should be startable in any path now 00122 * 00123 * Revision 1.1 2002/09/10 15:40:04 cvsadm 00124 * Created new project GT2003 (M.L.) 00125 * - Cleaned up the /Src/DataTypes directory 00126 * - Removed challenge related source code 00127 * - Removed processing of incoming audio data 00128 * - Renamed AcousticMessage to SoundRequest 00129 * 00130 * Revision 1.6 2002/07/23 13:38:22 loetzsch 00131 * moved Implementation of File into an own C++ file 00132 * 00133 * Revision 1.5 2002/07/14 14:03:07 roefer 00134 * First working gcc-version 00135 * 00136 * Revision 1.4 2002/07/09 15:24:53 dueffert 00137 * not nice but working 00138 * 00139 * Revision 1.3 2002/07/08 11:53:33 dueffert 00140 * further steps towards gcc 00141 * 00142 * Revision 1.2 2002/07/06 20:08:09 roefer 00143 * Advances towards gcc 00144 * 00145 * Revision 1.1.1.1 2002/05/10 12:40:18 cvsadm 00146 * Moved GT2002 Project from ute to tamara. 00147 * 00148 * Revision 1.10 2002/04/23 15:44:47 roefer 00149 * Comments added 00150 * 00151 * Revision 1.9 2002/04/23 15:19:42 roefer 00152 * Buffered file i/o 00153 * 00154 * Revision 1.8 2001/12/22 08:25:30 roefer 00155 * Enhanced constructor of class File, removed second one 00156 * 00157 * Revision 1.7 2001/12/13 13:12:27 risler 00158 * added #include <string.h> 00159 * 00160 * Revision 1.6 2001/12/12 15:19:52 juengel 00161 * if(stream != 0) im Destruktor vor fclose(stream); ergänzt. 00162 * 00163 * Revision 1.5 2001/12/10 17:47:08 risler 00164 * change log added 00165 * 00166 */