00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef OPENFILE_H
00021 #define OPENFILE_H
00022
00023 #include "copyright.h"
00024 #include "utility.h"
00025
00026 #ifdef FILESYS_STUB // Temporarily implement calls to
00027
00028
00029 class OpenFile {
00030 public:
00031 OpenFile(int f) { file = f; currentOffset = 0; }
00032 ~OpenFile() { Close(file); }
00033
00034 int ReadAt(char *into, int numBytes, int position) {
00035 Lseek(file, position, 0);
00036 return ReadPartial(file, into, numBytes);
00037 }
00038 int WriteAt(char *from, int numBytes, int position) {
00039 Lseek(file, position, 0);
00040 WriteFile(file, from, numBytes);
00041 return numBytes;
00042 }
00043 int Read(char *into, int numBytes) {
00044 int numRead = ReadAt(into, numBytes, currentOffset);
00045 currentOffset += numRead;
00046 return numRead;
00047 }
00048 int Write(char *from, int numBytes) {
00049 int numWritten = WriteAt(from, numBytes, currentOffset);
00050 currentOffset += numWritten;
00051 return numWritten;
00052 }
00053
00054 int Length() { Lseek(file, 0, 2); return Tell(file); }
00055
00056 private:
00057 int file;
00058 int currentOffset;
00059 };
00060
00061 #else // FILESYS
00062 class FileHeader;
00063
00064 class OpenFile {
00065 public:
00066 OpenFile(int sector);
00067
00068 ~OpenFile();
00069
00070 void Seek(int position);
00071
00072
00073 int Read(char *into, int numBytes);
00074
00075
00076
00077 int Write(char *from, int numBytes);
00078
00079 int ReadAt(char *into, int numBytes, int position);
00080
00081
00082 int WriteAt(char *from, int numBytes, int position);
00083
00084 int Length();
00085
00086
00087
00088
00089 private:
00090 FileHeader *hdr;
00091 int seekPosition;
00092 };
00093
00094 #endif // FILESYS
00095
00096 #endif // OPENFILE_H
The University of Southern California does not screen or control the content on this website and thus does not guarantee the accuracy, integrity, or quality of such content. All content on this website is provided by and is the sole responsibility of the person from which such content originated, and such content does not necessarily reflect the opinions of the University administration or the Board of Trustees