- Timestamp:
- 10/03/08 12:22:51 (3 months ago)
- Files:
-
- 1 modified
-
Whitix/branches/keobject/fs/kfs/dir.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
Whitix/branches/keobject/fs/kfs/dir.c
r976 r1064 7 7 #include <print.h> 8 8 9 /* TODO: Create KeFsEntry cache. */ 10 11 /* Returns number of entries in the directory. */ 9 12 int KeFsDirSize(struct KeFsDir* dir) 10 13 { … … 33 36 34 37 ListForEachEntry(entry,&dir->entries,next) 35 { 36 struct KeObject* object; 37 char* name; 38 39 object = (struct KeObject*)entry->file; 40 name = KeObjGetName(object); 41 42 if (strlen( name ) == nameLength && 43 !strnicmp(entry->name, name, nameLength)) 38 if (!strnicmp(name, entry->name, nameLength)) 44 39 goto found; 45 }46 40 47 41 /* Cycled through the whole directory with no luck */ … … 143 137 struct KeFsEntry* entry; 144 138 145 dir=KeFsNameToDir(dir, &name);146 147 if (!dir)148 return NULL;149 150 139 /* Check it doesn't exist already. */ 151 140 ListForEachEntry(entry, &dir->entries, next) 152 if (!strnicmp(entry->name, name, strlen(name)) )141 if (!strnicmp(entry->name, name, strlen(name)) && strlen(entry->name) == strlen(name)) 153 142 return entry; 154 143 … … 159 148 return NULL; 160 149 161 entry->type =VFS_ATTR_DIR | VFS_ATTR_READ;162 strcpy(entry->name, name);150 entry->type = VFS_ATTR_DIR | VFS_ATTR_READ; 151 entry->name = name; 163 152 164 153 newDir=&entry->dir; … … 176 165 { 177 166 struct KeFsEntry* entry; 178 179 dir=KeFsNameToDir(dir, &name);180 181 if (!dir)182 return NULL;183 167 184 168 /* Check if the name exists already */ 185 ListForEachEntry(entry, &dir->entries,next)186 if (!strnicmp(entry->name, name, strlen( entry->name)))169 ListForEachEntry(entry, &dir->entries, next) 170 if (!strnicmp(entry->name, name, strlen(name))) 187 171 return NULL; 188 172 189 173 /* Allocate the KeFsEntry, and the name with it */ 190 entry=(struct KeFsEntry*)MemAlloc(sizeof(struct KeFsEntry) +strlen(name)+1);174 entry=(struct KeFsEntry*)MemAlloc(sizeof(struct KeFsEntry)); 191 175 if (!entry) 192 176 return NULL; 193 177 194 entry->type =VFS_ATTR_FILE | permissions;195 strcpy(entry->name, name);178 entry->type = VFS_ATTR_FILE | permissions; 179 entry->name = name; 196 180 197 181 ListAddTail(&entry->next, &dir->entries); … … 204 188 void KeFsInitRoot(struct KeFsEntry* root) 205 189 { 206 root->type =VFS_ATTR_DIR | VFS_ATTR_READ;207 root->name [0]='\0';190 root->type = VFS_ATTR_DIR | VFS_ATTR_READ; 191 root->name = NULL; 208 192 INIT_LIST_HEAD(&root->dir.entries); 209 root->dir.parent =NULL;193 root->dir.parent = NULL; 210 194 } 211 195