delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/04/15:33:48

From: bukinm AT inp DOT nsk DOT su (Michael Bukin)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: open() question
Date: Sun, 03 Aug 1997 18:08:45 GMT
Organization: BINP SD RAS
Lines: 22
Message-ID: <33e4c77e.6770757@news-win.inp.nsk.su>
References: <33e1f561 DOT 1686433 AT news DOT pacific DOT net DOT sg>
Reply-To: bukinm AT inp DOT nsk DOT su
NNTP-Posting-Host: csd-bsdi.inp.nsk.su
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On Fri, 01 Aug 1997 14:48:03 GMT, fesenko AT pacific DOT net DOT sg (Victor)
wrote:

> I'm having a problem with open() function. As I understand using
> open("file.dat",O_RDWR|O_BINARY|O_CREAT)  a new file has to be created
> and if the file already existed, it would be rewritten. A problem
> shows when a file existed which had a bigger size than the file
> created. Then the file is rewritten, but it still shows the old size
> (which is bigger) and contains the remnants of an old file in the end.

  Try adding O_TRUNC to the open mode bits.
And, maybe you should add permissions, if you are creating file.
open ("file.dat", O_RDWR|O_BINARY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR);

Also, see:

info libc alpha open

for more info.

HTH

- Raw text -


  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019