Mercurial > sos > sos
view src/testFS.c @ 54:39fcefab46ed
Modified the init_fs function to take advantage of dynamic memory
init_fs (renamed) now takes advantage of dynamic memory and allocates space
for exactly as many direntries as it needs to keep track of
TODO redo caching to Jeff's far superior idea
author | Jonathan Pevarnek <pevarnj@gmail.com> |
---|---|
date | Sat, 09 Apr 2011 21:55:59 -0400 |
parents | 2de1c2597a60 |
children | 25be3895c62a |
line wrap: on
line source
#include <std.h> #include <fs.h> void dumpText(char *text, int size) { do { putline(text, (size > CON_LEN)?CON_LEN:size); size -= CON_LEN; text += CON_LEN; } while(size > 0); } void start(u64 __memsize) { init_all(__memsize); char buffer[256]; if(init_fs(0x100)) goto END; while(1) { //Prints off the name of each file listFiles(); char fname[28]; sPrint("Please enter the file to read: "); getFname(fname); u32 fid = lookupFile(fname); if(!fid) continue; //if fid is 0, the file was not found u32 fileSize; if(getFSize(fid, &fileSize)) continue; char *text = malloc(fileSize); if(getFData(fid, text)) continue; dumpText(text, fileSize); free(text); } END: sPrint("DONE\n"); for(;;) { sGet(buffer, 0); } }