HW1
This commit is contained in:
@@ -45,24 +45,23 @@ class FileSystem {
|
||||
FileSystem() { for (int i = 0; i < 20; i++) fileDescriptorTable[i] = NULL; }
|
||||
|
||||
bool Create(char *name) {
|
||||
int fileDescriptor = OpenForWrite(name);
|
||||
int fileDescriptor = OpenForWrite(name);
|
||||
|
||||
if (fileDescriptor == -1) return FALSE;
|
||||
Close(fileDescriptor);
|
||||
return TRUE;
|
||||
}
|
||||
if (fileDescriptor == -1) return FALSE;
|
||||
Close(fileDescriptor);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
OpenFile* Open(char *name) {
|
||||
int fileDescriptor = OpenForReadWrite(name, FALSE);
|
||||
int fileDescriptor = OpenForReadWrite(name, FALSE);
|
||||
|
||||
if (fileDescriptor == -1) return NULL;
|
||||
return new OpenFile(fileDescriptor);
|
||||
}
|
||||
if (fileDescriptor == -1) return NULL;
|
||||
return new OpenFile(fileDescriptor);
|
||||
}
|
||||
|
||||
bool Remove(char *name) { return Unlink(name) == 0; }
|
||||
|
||||
OpenFile *fileDescriptorTable[20];
|
||||
|
||||
OpenFile *fileDescriptorTable[20];
|
||||
};
|
||||
|
||||
#else // FILESYS
|
||||
@@ -87,9 +86,9 @@ class FileSystem {
|
||||
void Print(); // List all the files and their contents
|
||||
|
||||
private:
|
||||
OpenFile* freeMapFile; // Bit map of free disk blocks,
|
||||
OpenFile* freeMapFile; // Bit map of free disk blocks,
|
||||
// represented as a file
|
||||
OpenFile* directoryFile; // "Root" directory -- list of
|
||||
OpenFile* directoryFile; // "Root" directory -- list of
|
||||
// file names, represented as a file
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user