#include <PFS_Directory.h>
Inheritance diagram for PFS_Directory:


Public Member Functions | |
| PFS_Directory () | |
| PFS_Directory (unsigned long long blockNumber) | |
| void * | operator new (unsigned int size) |
| void * | operator new (unsigned int size, unsigned long long blockNumber) |
| void | operator delete (void *p) |
| char * | getName () |
| void | loadBlock (unsigned long long blockNumber) |
| unsigned long long | getBlockNo () |
| unsigned long long | getNumberOfFile () |
| unsigned long long | getNumberOfDirectory () |
| FileOrDirectoryLinks_struct | getFileOrDirectoryLink (unsigned long long index) |
| bool | operator= (PFS_Directory v) |
| unsigned long long | getBlockNumber () |
| dirent * | readdir () |
Private Attributes | |
| unsigned long long | blockNumber |
| char | id [4] |
| char | directoryName [501] |
| unsigned long long | numberOfFile |
| unsigned long long | numberOfDirectory |
| char | permission [9] |
| unsigned long long | createTime |
| unsigned long long | lastModifiedTime |
| unsigned long long | directoryIndirectBlock |
| unsigned int | directory_read |
| FileOrDirectoryLinks_struct | fileOrDirectoryLinks [NUMBER_OF_FILEORDIRECTORYLINKS] |
|
|
Definition at line 8 of file PFS_Directory.cpp. References directory_read. 00009 {
00010 directory_read = 0;
00011 }
|
|
|
Definition at line 13 of file PFS_Directory.cpp. References directory_read, and loadBlock(). 00014 {
00015 this->blockNumber = blockNumber;
00016 directory_read = 0;
00017 loadBlock(blockNumber);
00018 }
|
|
|
Definition at line 25 of file PFS_Directory.cpp. References blockNumber. Referenced by cd(). 00026 {
00027 return blockNumber;
00028 }
|
|
|
Definition at line 20 of file PFS_Directory.cpp. References blockNumber. 00021 {
00022 return blockNumber;
00023 }
|
|
|
Definition at line 123 of file PFS_Directory.cpp. References fileOrDirectoryLinks. Referenced by PFS_Main::findDirectory(), and PFS_Main::findFile(). 00124 {
00125 return fileOrDirectoryLinks[index];
00126 }
|
|
|
Definition at line 3 of file PFS_Directory.cpp. References directoryName. Referenced by PFS_Main::findDirectory(), PFS_Main::findFile(), and operator=(). 00004 {
00005 return directoryName;
00006 }
|
|
|
Definition at line 94 of file PFS_Directory.cpp. References numberOfDirectory. Referenced by PFS_Main::findDirectory(), and PFS_Main::findFile(). 00095 {
00096 return numberOfDirectory;
00097 }
|
|
|
Definition at line 89 of file PFS_Directory.cpp. References numberOfFile. Referenced by PFS_Main::findDirectory(), and PFS_Main::findFile(). 00090 {
00091 return numberOfFile;
00092 }
|
|
|
Definition at line 30 of file PFS_Directory.cpp. References BLOCKSIZE, convert(), createTime, directoryIndirectBlock, directoryName, fileOrDirectoryLinks, PFS_Main::getPFSMain(), FileOrDirectoryLinks_struct::id, lastModifiedTime, numberOfDirectory, numberOfFile, and permission. Referenced by operator new(), and PFS_Directory(). 00031 {
00032 unsigned char bytes[4096];
00033 /*unsigned int byteRead = readSector(PARTITIONOFFSET / 512, 0,
00034 0 + blockNumber * 8 + SUPERBLOCKSIZE / 512, bytes, 8 * 512); */
00035
00036 unsigned int byteRead = PFS_Main::getPFSMain()->readBlock(bytes, blockNumber);
00037 if (byteRead != BLOCKSIZE) {
00038 return;
00039 }
00040
00041
00042 id[0] = bytes[0];
00043 id[1] = bytes[1];
00044 id[2] = bytes[2];
00045 id[3] = '\0';
00046
00047
00048 for (unsigned int x = 0; x < 500; x++) {
00049 directoryName[x] = bytes[x + 3];
00050 }
00051 directoryName[500] = '\0';
00052 //print("directoryName=%s\n",directoryName);
00053
00054 numberOfFile = bytes[503] + (bytes[504] << 8) + (bytes[505] << 16) + (bytes[506] << 24);
00055 //print("numberOffile=%u\n",numberOfFile);
00056 numberOfDirectory = bytes[507] + (bytes[508] << 8) + (bytes[509] << 16) + (bytes[510] << 24);
00057 //print("numberOfDirectory%u\n",numberOfDirectory);
00058
00059 permission[0] = bytes[511];
00060 permission[0] = bytes[512];
00061 permission[0] = bytes[513];
00062 permission[0] = bytes[514];
00063 permission[0] = bytes[515];
00064 permission[0] = bytes[516];
00065 permission[0] = bytes[517];
00066 permission[0] = bytes[518];
00067 permission[0] = bytes[519];
00068
00069 // createTime = bytes[520] + (bytes[521] << 8) + (bytes[522] << 16) + (bytes[523] << 24) + (bytes[524] << 32) + (bytes[525] << 40) + (bytes[526] << 48) + (bytes[527] << 56);
00070 convert(bytes + 520, &createTime);
00071 // lastModifiedTime = bytes[528] + (bytes[529] << 8) + (bytes[530] << 16) + (bytes[531] << 24) + (bytes[532] << 32) + (bytes[533] << 40) + (bytes[534] << 48) + (bytes[535] << 56);
00072 convert(bytes + 528, &lastModifiedTime);
00073 // directoryIndirectBlock = bytes[536] + (bytes[537] << 8) + (bytes[538] << 16) + (bytes[539] < 24) + (bytes[540] << 32) + (bytes[541] << 40) + (bytes[542] << 48) + (bytes[543] << 56);
00074 convert(bytes + 536, &directoryIndirectBlock);
00075
00076 for (unsigned int x = 0; x < ((BLOCKSIZE - 544) / sizeof(FileOrDirectoryLinks_struct)) - 9; x++) {
00077 fileOrDirectoryLinks[x].id = bytes[544 + x * 9];
00078 // fileOrDirectoryLinks[x].link = bytes[544 + x * 9 + 1] + (bytes[544 + x * 9 + 2] << 8) + (bytes[544 + x * 9 + 3] << 16) + (bytes[544 + x * 9 + 4] << 24) + (bytes[544 + x * 9 + 5] << 32) + (bytes[544 + x * 9 + 6] << 40) + (bytes[544 + x * 9 + 7] << 48) + (bytes[544 + x * 9 + 8] << 56);
00079 convert(bytes + (544 + x * 9 + 1), &fileOrDirectoryLinks[x].link);
00080 }
00081 }
|
|
|
|
|
||||||||||||
|
Definition at line 110 of file PFS_Directory.cpp. References blockNumber, kmalloc(), and loadBlock(). 00111 {
00112 PFS_Directory *dir = (PFS_Directory *) kmalloc(size);
00113 dir->blockNumber = blockNumber;
00114 dir->loadBlock(blockNumber);
00115
00116 if (dir != NULL) {
00117 return dir;
00118 } else {
00119 return (void *) NULL;
00120 }
00121 }
|
|
|
Definition at line 99 of file PFS_Directory.cpp. References kmalloc(). 00100 {
00101 void *dir = kmalloc(sizeof(PFS_Directory));
00102 ((PFS_Directory *) dir)->blockNumber = blockNumber;
00103 if (dir != NULL) {
00104 return dir;
00105 } else {
00106 return (void *) NULL;
00107 }
00108 }
|
|
|
Definition at line 83 of file PFS_Directory.cpp. References getName(), and strncpy().
|
|
|
Reimplemented from DIR. Definition at line 128 of file PFS_Directory.cpp. References dirent::d_name, directory_read, directoryName, fileOrDirectoryLinks, PFS_File::getName(), kmalloc(), strcpy(), and strlen(). 00129 {
00130 struct dirent *temp = (struct dirent *) kmalloc(sizeof(struct dirent));
00131 if (fileOrDirectoryLinks[directory_read].link == 0) {
00132 return NULL;
00133 } else {
00134 if (fileOrDirectoryLinks[directory_read].id == 1) {
00135 PFS_Directory subDirectory(fileOrDirectoryLinks[directory_read].link);
00136 temp->d_name = (char *) kmalloc(strlen(subDirectory.directoryName) + 1);
00137 strcpy(temp->d_name, subDirectory.directoryName);
00138 } else {
00139 PFS_File subFile(fileOrDirectoryLinks[directory_read].link);
00140 temp->d_name = (char *) kmalloc(strlen(subFile.getName()) + 1);
00141 strcpy(temp->d_name, subFile.getName());
00142 }
00143 directory_read++;
00144 return temp;
00145 }
00146 }
|
|
|
Definition at line 8 of file PFS_Directory.h. Referenced by getBlockNo(), getBlockNumber(), and operator new(). |
|
|
Definition at line 14 of file PFS_Directory.h. Referenced by loadBlock(). |
|
|
Definition at line 17 of file PFS_Directory.h. Referenced by PFS_Directory(), and readdir(). |
|
|
Definition at line 16 of file PFS_Directory.h. Referenced by loadBlock(). |
|
|
Definition at line 10 of file PFS_Directory.h. Referenced by getName(), loadBlock(), and readdir(). |
|
|
Definition at line 18 of file PFS_Directory.h. Referenced by getFileOrDirectoryLink(), loadBlock(), and readdir(). |
|
|
Definition at line 9 of file PFS_Directory.h. |
|
|
Definition at line 15 of file PFS_Directory.h. Referenced by loadBlock(). |
|
|
Definition at line 12 of file PFS_Directory.h. Referenced by getNumberOfDirectory(), and loadBlock(). |
|
|
Definition at line 11 of file PFS_Directory.h. Referenced by getNumberOfFile(), and loadBlock(). |
|
|
Definition at line 13 of file PFS_Directory.h. Referenced by loadBlock(). |
1.4.2