1

I use Visual Basic 6.0. It is possible "Processing Files with Older File I/O" as it is said using VB6. Files can be reached as "random" using this I/O. It gives opportunity to read and write parts of the file. I wonder if just a -random- part of a file is changed using this I/O, is it really be updated just that part of the record on hard drive, or whole changed file is recorded, i.e. written from beginnig to end.

1 Answers1

2

I use Visual Basic 6.0. It is possible "Processing Files with Older File I/O" as it is said using VB6. Files can be reached as "random" using this I/O. It gives opportunity to read and write parts of the file. I wonder if just a -random- part of a file is changed using this I/O, is it really be updated just that part of the record on hard drive, or whole changed file is recorded, i.e. written from beginnig to end.

Yes, it can update just that part – programs can directly seek to and write individual bytes.

The OS handles it with a minimum granularity of a 'cluster' or 'block' or 'allocation unit', which is often 4 kB or a similar power-of-two (chosen when formatting the file system). Though depends on the OS and the file system; certain "copy on write" filesystems such as ZFS might rewrite an entire 'record' (which could be as large as 128 kB or even 4 MB).

The absolute minimum for disk random access is usually one disk sector, typically either 512 bytes or 4096 bytes for HDDs. (On SSDs it is physically larger but they nevertheless emulate 512-byte sectors in their firmware.)

So if you update a single byte, the OS will need to read and rewrite at least a 512-byte sector – but generally not the whole file.

grawity
  • 501,077