view src/testFS.c @ 52:2de1c2597a60

Modified getFSize so it now returns a value indicating success/failure Also modified the lookup function so it does not load the file into the cache
author Jonathan Pevarnek <pevarnj@gmail.com>
date Sat, 09 Apr 2011 01:28:06 -0400
parents eda059d74100
children 39fcefab46ed
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_io_int();
	init_console();
	malloc_init(__memsize - HEAP_START);
	char buffer[256];
	if(fsInit(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);
	}
}