[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with ProDOS file structure!



In article <phandel.2s25@sempco.uucp>,
Peter Handel <phandel@sempco.uucp> wrote:
> >Your problem is that all the blocks but the first have been
> >deallocated. In addition to correcting the length of the file and
> >blocks used count, you would have to find each block that was
> >originally part of the file, get them in order, and reconstruct the
> >mapping
>  
> I often optimize my HD, so they should all be in order.

Not necessarily.  There are likely to be index blocks in unusual
places within the file, unless it was smaller than 128k.

When a file is written sequentially, to an unused area of the disk,
the usual block order is <1st data> <index> <2nd data> <3rd data> ...
because ProDOS sets up a single-block "seedling" file first, then
discovers you want to write more than one block, so it has to change
it to a "sapling" file and add an index block.  The next 255 data
blocks follow.  If you write still more data, it is changed to a "tree"
file, with a two-level index.  A "master index" block is written,
followed by another index block, followed by further data blocks.

The optimizer might have rearranged the order of the blocks, and even
if you had optimized the drive recently, it is still possible that the
file might be slightly fragmented.

You cannot assume that the blocks are in any particular place - you
have to find the index block (or master index block) to locate all of
the data blocks.  The index block is located via the directory entry,
but that will have been overwritten or changed when you saved the file.

> >Anything you try to solve this problem is dangerous, and takes lots of
> >time. It is always much easier to undelete a file than to lengthen it.
>  
> The problem is that the file is present, it's not actually deleted!  It's
> just a lot shorter than I want it to be

Yes, but to do that, the program will have done any of the following:

(a) Delete the original file, then create a new one with the same
name.  This will have re-used the directory entry (overwriting the
information needed to locate the deleted file) and probably
overwritten the first (or first few) data and/or index blocks of the
original file.

(b) Cut the file size back to zero bytes, then written new data to the
file.  This is effectively the same - the first block (or blocks) of
the file will have been overwritten, and the index block may have been
lost in the process.

(c) Saved the file under a new name, then deleted the original file
and renamed the new file to match the original one (or renamed the
original file before saving, but this is unusual).  In this case, you
should be able to undelete the original file, because its directory
entry and all blocks will be intact.

Method (c) is rare.  AppleWorks is one of the few programs that does this.

To undelete files, you should get a utility program.  Undeleting files
by hand is not easy.

> And what's a "Case Implementation?"

Pass.
-- 
David Empson
dempson@actrix.gen.nz
Snail mail: P.O. Box 27-103, Wellington, New Zealand