view testfs.c @ 510:43ea59887c69

Start work on making C64 formats encoding possible by changing DMDecodeOps to DMEncDecOps and adding fields and op enums for custom encode functions, renaming, etc. Split generic op sanity checking into a separate function in preparation for its use in generic encoding function.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 19 Nov 2012 15:06:01 +0200
parents 32250b436bca
children
line wrap: on
line source

#include "d_fs.h"
#include <stdarg.h>
#include <stdio.h>

void dream_error(const char *pFmt, ...)
{
 va_list myAP;
 fprintf(stderr, "testfs: "); 
 va_start(myAP, pFmt);
 vfprintf(stderr, pFmt, myAP);
 va_end(myAP);
 fprintf(stderr, "\n");
}

int main(void)
{
 DINT iResult;
 t_d_file *f;

 /* Initialize dreamFS
  */
 iResult = dream_fs_init(DTRUE, DFALSE);
 fprintf(stderr, "dream_fs_init(): %i\n", iResult);
 if (iResult != DREAM_ERR_OK) return 1;

 /* File reading test, output "README" to stdout
  */
 f = dfopen("README");
 if (!f)
 	fprintf(stderr, "dfopen() failed\n");
 	else
 	{
 	fprintf(stderr, "dfopen(%s) ok, fops = %p\n", f->pcFilename, f->fops);
	dfclose(f);
 	}
 


 /* Try opening a file which is not in the PACK
  */
 f = dfopen("jeejee.jpg");
 if (!f)
 	fprintf(stderr, "dfopen() failed\n");
 	else
 	{
 	fprintf(stderr, "dfopen(%s) ok, fops = %p\n", f->pcFilename, f->fops);
 	dfclose(f);
 	}

 f = dfopen("jeejee.jpgz");
 if (!f)
 	fprintf(stderr, "dfopen() failed (as expected)\n");
 	else
 	{
 	fprintf(stderr, "dfopen(%s) ok, fops = %p\n", f->pcFilename, f->fops);
 	dfclose(f);
 	}

 fprintf(stderr, "dream_fs_close()\n"); dream_fs_close();

 return 0;
}