jcreedcmu / twelf-mac

Other
0 stars 1 forks source link

Files are never truncated #7

Closed jcreedcmu closed 3 months ago

jcreedcmu commented 3 months ago

Steps to reproduce:

It seems that whenever we save a file, even when we do

OSErr writeFile(TEHandle te, FSSpec *spec) {
  OSErr err;
  short refNum;
  err = FSpOpenDF(spec, fsRdWrPerm, &refNum);
  Handle textHandle = (Handle)TEGetText(te);
  long size = (*te)->teLength;
  err = SetFPos(refNum, fsFromStart, 0);
  err = FSWrite(refNum, &size, *textHandle);
  err = SetEOF(refNum, size);
  err = FSClose(refNum);
  return err;
}

the EOF of the file is not saved. Inside Macintosh suggests we should call FlushVol after FSClose, but alas, FlushVol is not apparently supported by multiversal.

agoode commented 3 months ago

I think this might be a problem more generally in libretro. I noticed that fopen("foo", "w"); was not properly truncating.

agoode commented 3 months ago

https://github.com/autc04/multiversal/pull/5

jcreedcmu commented 3 months ago

Fixed by above PR and 894f2be0c57f2f1a7e6981a4e979ad04197f7932 actually calling SetEOF.