Added code to flush unwritten changes to disk

This commit is contained in:
Bobbi Webber-Manners 2020-02-22 22:45:22 -05:00
parent 4925baeaa5
commit 43abef7f98

View File

@ -155,6 +155,7 @@ static char caseopts[2] = ""; /* -c:x case conversion option */
/* Prototypes */ /* Prototypes */
void prerr(char *s); void prerr(char *s);
void hline(void); void hline(void);
void flushall(void);
int readdiskblock(uchar device, uint blocknum, char *buf); int readdiskblock(uchar device, uint blocknum, char *buf);
int writediskblock(uchar device, uint blocknum, char *buf); int writediskblock(uchar device, uint blocknum, char *buf);
void fixcase(char *in, char *out, uchar minvers, uchar vers, uchar len); void fixcase(char *in, char *out, uchar minvers, uchar vers, uchar len);
@ -210,6 +211,17 @@ void hline(void) {
putchar('-'); putchar('-');
} }
/*
* Disable GSOS block cache and flush any unwritten changes
*/
void flushall(void) {
ResetCacheGS(0); /* Disable block caching */
short ff[2];
ff[0] = 1;
ff[1] = 0;
FlushGS(ff);
}
/* /*
* Read block from disk using ProDOS call * Read block from disk using ProDOS call
* buf must point to buffer with at least 512 bytes * buf must point to buffer with at least 512 bytes
@ -249,7 +261,7 @@ int writediskblock(uchar device, uint blocknum, char *buf) {
puts("Not writing library directory"); puts("Not writing library directory");
return 0; return 0;
} }
ResetCacheGS(0); /* Disable block caching */ flushall();
DIORecGS dr; DIORecGS dr;
dr.pCount = 6; dr.pCount = 6;
dr.devNum = device; dr.devNum = device;
@ -1360,6 +1372,7 @@ void usage(void) {
* blocknum is the keyblock of the directory to process * blocknum is the keyblock of the directory to process
*/ */
void processdir(uint device, uint blocknum) { void processdir(uint device, uint blocknum) {
flushall();
uchar err = readdir(device, blocknum); uchar err = readdir(device, blocknum);
if (doverbose) { if (doverbose) {
printlist(); printlist();