stevep@galadriel.bt.co.uk (Steve Paine) (02/28/90)
Could someone give me a starting point on how to truncate an AmigaDOS file in 'C' please. (e.g taking, say, 20 bytes off the end.) Just copying the (file - number_of_bytes_to_reduce_by) is not going to be good enough because as I will only be taking a maximum of 100 bytes off, and on a floppy too, I will have a prob with files bigger than 400 Kbytes - it wont fit on a floppy. (Yes, I will have a file that big, its hopefuly going to be a database!) I need something along the lines of the SunOs function truncate() if thats any help to you. Any help will be greatly appreciated. Steve Paine. British Telecom Research labs, Martlesham, Ipswich, ENGLAND.
d88-skl@nada.kth.se (Stellan Klebom) (03/01/90)
In article <591@galadriel.bt.co.uk> stevep@galadriel.bt.co.uk (Steve Paine) writes: >Could someone give me a starting point on how to truncate an AmigaDOS file >in 'C' please. (e.g taking, say, 20 bytes off the end.) Just copying the >(file - number_of_bytes_to_reduce_by) is not going to be good enough because as >I will only be taking a maximum of 100 bytes off, and on a floppy too, I will >have a prob with files bigger than 400 Kbytes - it wont fit on a floppy. >(Yes, I will have a file that big, its hopefuly going to be a database!) >I need something along the lines of the SunOs function truncate() if thats >any help to you. > > Any help will be greatly appreciated. > > Steve Paine. > British Telecom Research labs, > Martlesham, > Ipswich, > ENGLAND. Truncating a file under Amiga DOS is only possibel under FastFileSystem. But there is no system call, so you have to deal with it at packet level. Under the old filesystem, the only thing you can do is to make a copy of the file with the part you want to truncate left out. Well, maybe ther is a way to do it but the you have to fiddle directly with the sectors on disk. Stellan ------------------------------------------------------------------------------- E-Mail: UUNET: d88-skl@nada.kth.se * #include <std-disclaimer.h> UUCP: uunet!sunic!nada!d88-skl * * You'll never now, Snail-Mail: Stellan Klebom * tomorrow may be cancelled! Axvaegen 6 * S-175 44 JAERFAELLA * SWEDEN * (Yet another intelligent statement) -------------------------------------------------------------------------------
new@udel.edu (Darren New) (03/01/90)
In article <3042@draken.nada.kth.se> d88-skl@nada.kth.se (Stellan Klebom) writes: >Well, maybe ther is a way to do it >but the you have to fiddle directly with the sectors on disk. Be advised that under the OFS there are MANY places where the length is stored. What is shown by LIST is not what is copied by COPY and is not necessarily what is used by Seek(). Take this from one who tried to use DiskEd to chop the Control-Zs from executables downloaded by XModem. A better way would be to store in the first longword of the database a number saying how many valid bytes are in the file. You could even have a utility that would copy the file to another (or the same) floppy that would only copy the indicated number of bytes. Then the user would not have to wait everytime a record was deleted for you to copy 400K+ from one place on the floppy to another. Good luck! -- Darren