cen@drufl.UUCP (Nguyen) (12/01/84)
A directory entry for a file only contains the number of blocks. How can you tell how long (in bytes) a file is ? Does the DOS keep this information somewhere ? does file type matter? -- V. Hoang AT&T Technologies, Denver ihnp4!dwx3bS!vqh
miller@uiucdcsb.UUCP (12/02/84)
To answer your question on the c64 1541 files: The directory contains the # of sectors used in the file. Each sector contains 256 bytes. The first two are used as a chain to the next sector in the file (leaving 254 for data) *except* in the last sector, where the # of bytes in that final sector is stored. A. Ray Miller Univ Illinois
dillon@ucbvax.ARPA (The Sherif "Matt D.") (12/04/84)
> To answer your question on the c64 1541 files: > The directory contains the # of sectors used in the file. Each sector contains > 256 bytes. The first two are used as a chain to the next sector in the file > (leaving 254 for data) *except* in the last sector, where the # of bytes in > that final sector is stored. > > A. Ray Miller > Univ Illinois I believe the sector entry for the last block is an index to the last byte, not the number of bytes remaining. I.e., it must skip over the first two bytes which are the track(0) and index. I don't have the specs in front of me, so I forgot whether the pointer is to the LAST byte, or one past the last byte. Matthew Dillon
lenoil@mit-eddie.UUCP (Robert Scott Lenoil) (12/05/84)
>A directory entry for a file only contains the number of blocks. >How can you tell how long (in bytes) a file is ? Does the DOS >keep this information somewhere ? does file type matter? No, the Commodore DOS does not maintain a record of a file's size, beyond the number of blocks. Usually, this is sufficient, as you just multiply this number by 254, the number of bytes in a block minus the two byte pointer to the next block in the file. If you want to get an exact count, probably the easiest way would be to open the file for read, and read it in byte by byte, counting as you go. Otherwise, you'd have to chain through the file blocks on the disk to get at the last block (the only one that may have less than 254 bytes in it). I don't remember for sure how they mark the last byte in this block, but it's probably by the sector byte of the next-block pointer (the track byte will be zero, signalling the last block of the chain). Robert Lenoil USENET: {ihnp4,decvax!genrad,godot,harvard}!mit-eddie!lenoil ARPANET: lenoil@mit-xx.arpa