sft@ihlpa.ATT.COM (Scott Thompson) (05/10/89)
I want to read, process and write, a possibly smaller (truncate), mail file in a single locked open. Currently I can read, process and write the file originally opened with fopen and "r+", but it will not truncate if the new file is shorter; I also tried other combinations along with open, but they truncate the file prior to reading! This is for use under SYSV for file locking a mail file. Any and all suggestions will be appreciated. Thanks -- -- Scott Thompson (IH 6W-207), AT&T Bell Labs, Naperville, Il. 60566 VOICE: (312)-979-2237 UUCP: ...!att!ihlpa!sft
chris@mimsy.umd.edu (Chris Torek) (11/12/89)
In article <986@dialogic.UUCP> drich@dialogic.UUCP (Dan Rich) writes: > int ftruncate(fd,length) > int fd; > off_t length; >ftruncate() causes the file refered to by fd to have a size >equal to length bytes. ... If it was shorter, bytes between the >old and new lengths are read as zeros. Unless it is a BSD system (i.e., not a SunOS system), in which case ftruncate does what its name suggests: *truncates* the file, rather than set its size. In other words, if it was shorter, the file remains shorter. It would have been nice if, while changing the operation, Sun had changed the name as well. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@cs.umd.edu Path: uunet!mimsy!chris