POV-Ray : Newsgroups : povray.off-topic : A retro moment : Re: A retro moment Server Time
29 Jul 2024 18:30:11 EDT (-0400)
  Re: A retro moment  
From: Darren New
Date: 7 Jun 2011 09:51:21
Message: <4dee2cd9$1@news.povray.org>
On 6/7/2011 6:39, Francois Labreque wrote:
> This is why you have to update the FAT everytime you use a
> block, and the directory everytime you write a file.

Technically, you only need to update the FAT when you close the file. If you 
haven't recorded the length of the file, you don't really care if the space 
is marked as used in the FAT.

I.e., if you create a zero-length file name in the directory, then start 
writing the file, modifying a cached version of the FAT as you write, and 
then the power goes out (or the disk gets pulled), then the FAT says the 
space is unallocated and the directory says the file is unallocated, so 
you're OK.

So I think (IIRC) it writes the zero-length file to the directory, then 
reads the FAT, then writes the file data while updating the FAT sector, then 
finishes by flushing the final changes to the FAT and then going back to 
update the directory to point to the first block in the chain.

It also flushes the FAT sector whenever it moves to allocating from a 
different FAT sector, which is why you'll hear it write a few tracks, then 
crank back and forth, then write a few more tracks, then crank back and 
forth, as you copy a large file.

-- 
Darren New, San Diego CA, USA (PST)
   "Coding without comments is like
    driving without turn signals."


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.