home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!spool.mu.edu!agate!apple!mumbo.apple.com!gallant.apple.com!seuss.apple.com!user
- From: absurd@apple.apple.com (Tim Dierks, software saboteur)
- Subject: Re: Possible Bug with fseek in MPW C 3.2.4?
- Sender: news@gallant.apple.com
- Message-ID: <absurd-171292134336@seuss.apple.com>
- Date: Thu, 17 Dec 1992 21:51:11 GMT
- References: <57670@dime.cs.umass.edu>
- Organization: MacDTS Marauders
- Followup-To: comp.sys.mac.programmer
- Lines: 43
-
- In article <57670@dime.cs.umass.edu>, cook@cs.umass.edu (Robert Cook)
- wrote:
- >
- > I'm trying to increase the size of a file using the function fseek with
- > no luck,
- > i.e.
- > err=fseek(fp,offset,SEEK_END);
- > the fseek statement returns back an error, -1.
- >
- > According to the book "C - A Reference Manual" third edition, by Samuel
- > P. Harbison and
- > Guy L. Steele Jr. this is possible, and I quote from pg 305, "If
- > wherefrom is SEEK_END
- > and offset is positive, then the file is extended the indicated amount
- > from it end with
- > unspecified contents."
- >
- > The MPW 3.0 C Reference Manual also eludes to this fact by stating on pg
- > 122, "If whence
- > is SEEK_END, the new position is the size of the file plus offset." But
- > on pg 123 it states
- > under "Return values", "An example of an improper seek is an fseek before
- > the beginning of,
- > or past the end of, the file."
- >
- > So what gives, can I use fseek to increase the size of a file?
- > If so, does this mean MPW C 3.2.4 has a bug in it?
- >
- > Thanks,
- >
- > Bob Cook
- > Computer Science Department
- > University of Massachusetts
- > Amherst, MA 01003
-
- Nope, you can't use fseek to increase the size of a file; thus, SEEK_END
- is only useful with an offset that is less than or equal to zero. To
- set the size of a file, use ioctl with the FIOSETEOF selector. This is
- described on page 125 of the MPW C 3.1 reference.
-
- Enjoy,
- Tim Dierks
- MacDTS pinball addict
-