t-w / ADFlib

A free, portable and open implementation of the Amiga filesystem
GNU General Public License v2.0
0 stars 1 forks source link

Write support... #2

Closed t-w closed 7 months ago

t-w commented 1 year ago

Plenty to fix (see also lclevy/ADFlib#30). I will put some notes on this here.

t-w commented 1 year ago

Probably have to start from putting diagnostics on everything possible - in many cases return status of the functions is not checked...

t-w commented 1 year ago

File (object) state management seems overcomplex, hard to debug and make robust:

But... if there will be no reasonable way to untangle and simplify it, it may be necessary to redesign and rewrite the whole adf_file module...

t-w commented 1 year ago

File size in file header in set only in adfFlushFile in the following way:

  file->fileHdr->byteSize = file->pos;

meaning:

  1. it is inconsistent while writing data
  2. when writing something inside a file, the size will shrink to the last position after writing(!)
t-w commented 1 year ago

Invalidating current data block buffer (.currentData in struct adfFile) seems best to be done by setting .curDataPtr to 0 (no data block can be stored in sector/block 0). Otherwise eg. a new var. will have to be introduced (but this increases amount of things to keep consistent as state...).

t-w commented 1 year ago

Should seek operations read/write data?

If seek will not read/write data:

If going for the second (dropping any data operations when seeking):

To decide... (dropping data ops seems simpler -> more robust -> better?).

t-w commented 1 year ago

So, after a few approaches decided to go back to what was there. Mentioned above things (dropping data operation when seeking etc. would require deep redesign (maybe even rewriting most) of the file api module. So in the end - keeping original way - current datablock always in the buffer (unless no data - an empty file)

Maybe some future revision or a fork/rewrite will change this. For now - it works well enough.

t-w commented 1 year ago

One thing is missing - seeking while writing (after a write operation) should write current buffer (can be modified). The trouble is that there is no info whether the buffer was modified... Just adding writing the buffer would write on every seek operation (in write mode)... No sure what to do with it, yet...

(but to implement somehow - with a test).

t-w commented 7 months ago

Volume filesystem write support was completed for 0.8.0.

The remaining thing, updating block allocation bitmap, was added recently (lclevy#64).