Thread View: comp.os.msdos.programmer
1 messages
1 total messages
Started by Ralf.Brown
Tue, 31 Jul 1990 11:15
Re: Truncate a File?
Author: Ralf.Brown
Date: Tue, 31 Jul 1990 11:15
Date: Tue, 31 Jul 1990 11:15
33 lines
1777 bytes
1777 bytes
In article <10914@spool.cs.wisc.edu>, rose@galtee.cs.wisc.edu (Barney Frank) wrote:
}I have a requirement to adjust the length of a data file.
}
}4. Ask the operating system to adjust the size of the file down to the new
} "high-water" mark.
}
} It is not sufficient to make a temporary copy of the section of
}interest, unlink the original file, and rename the temporary, because
}the size of the file is of the same order of that of the file system.
}This sounds like a pretty elementary operation to me, but I'll be
}damned if I can find a system call to do anything to the size of a
}file other than just move it down to zero. One can envision some
Ever since DOS 1.00, a WRITE of *zero* bytes has set the file size to the
current file position. So, for example:
mov ax,4200h
mov bx,handle
mov cx,0
mov dx,1234h
int 21h
mov ah,40h
mov bx,handle
xor cx,cx
int 21h
will set the size of the file corresponding to 'handle' to 1234h bytes.
--
UUCP: {ucbvax,harvard}!cs.cmu.edu!ralf -=- 412-268-3053 (school) -=- FAX: ask
ARPA: ralf@cs.cmu.edu BIT: ralf%cs.cmu.edu@CMUCCVMA FIDO: 1:129/3.1
Disclaimer? | I was gratified to be able to answer promptly, and I did.
What's that? | I said I didn't know. --Mark Twain
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads