1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-11-19 12:32:08 +00:00
C02/test/fstest.c02

81 lines
1.5 KiB
Plaintext
Raw Normal View History

/*****************************************
* FSTEST - Test/Demo Module filesys.h02 *
*****************************************/
//Specify System Header using -H option
#include <screen.h02>
#include <stddef.h02>
#include <stdlib.h02>
#include <intlib.h02>
#include <stdio.h02>
#include <stdiox.h02>
#include <string.h02>
#include <fileio.h02>
#include <filesys.h02>
const char dir = "TEMPDIR";
const char oldnam = "OLDFILE.TMP";
const char newnam = "NEWFILE.TMP";
char d, e, err, f, i, n, r;
char m[128];
char aa,xx,yy;
main:
newfil();
renfil();
delfil();
prtdrv();
chgdrv();
goto exit;
void chkerr() {
puts(": ");
if (err) {
e = ferror(0, &m);
printf(e, "ERROR %d - ");
putln(&m);
}
else if (r) putln("FAILED");
else putln("SUCCESS");
}
void prtdrv() {
d, err = getdrv(); printf(d,"GETDRV: %d "); chkerr();
printf(drvnam(d), "DRVNAM: '%c'"); chkerr();
}
void newfil() {
puts("CREATING FILE "); puts(oldnam);
f, err = fopen(#MWRITE, oldnam); chkerr();
puts("WRITING TO FILE ");
n, err = fputln(f, "FILE CONTENTS"); chkerr();
puts("CLOSING FILE ");
err = fclose(f); chkerr();
}
void renfil() {
puts("RENAMING "); puts(oldnam);
puts(" TO "); puts(newnam);
fsname(oldnam);
r, err = rename(newnam); chkerr();
}
void delfil() {
puts("REMOVING "); puts(newnam);
r, err = remove(newnam); chkerr();
}
void chgdrv() {
for (i=0; i<#DRIVES; i++) {
d = drive[i];
printf(d, "CHDRV(%d) ");
printf(drvnam(d), "'%c'");
r, err = chdrv(d); chkerr();
}
}
error:
printf(err, "ERROR %d%n");
goto exit;