home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / mac / programm / 19996 < prev    next >
Encoding:
Text File  |  1992-12-18  |  1.9 KB  |  56 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. 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
  3. From: absurd@apple.apple.com (Tim Dierks, software saboteur)
  4. Subject: Re: Possible Bug with fseek in MPW C 3.2.4?
  5. Sender: news@gallant.apple.com
  6. Message-ID: <absurd-171292134336@seuss.apple.com>
  7. Date: Thu, 17 Dec 1992 21:51:11 GMT
  8. References: <57670@dime.cs.umass.edu>
  9. Organization: MacDTS Marauders
  10. Followup-To: comp.sys.mac.programmer
  11. Lines: 43
  12.  
  13. In article <57670@dime.cs.umass.edu>, cook@cs.umass.edu (Robert Cook)
  14. wrote:
  15. > I'm trying to increase the size of a file using the function fseek with
  16. > no luck,
  17. > i.e.
  18. >            err=fseek(fp,offset,SEEK_END);
  19. > the fseek statement returns back an error, -1.
  20. > According to the book "C - A Reference Manual" third edition, by Samuel
  21. > P. Harbison and
  22. > Guy L. Steele Jr. this is possible, and I quote from pg 305, "If
  23. > wherefrom is SEEK_END
  24. > and offset is positive, then the file is extended the indicated amount
  25. > from it end with
  26. > unspecified contents."
  27. > The MPW 3.0 C Reference Manual also eludes to this fact by stating on pg
  28. > 122, "If whence
  29. > is SEEK_END, the new position is the size of the file plus offset."  But
  30. > on pg 123 it states
  31. > under "Return values", "An example of an improper seek is an fseek before
  32. > the beginning of,
  33. > or past the end of, the file."
  34. > So what gives,  can I use fseek to increase the size of a file?
  35. > If so, does this mean MPW C 3.2.4 has a bug in it?
  36. > Thanks,
  37. > Bob Cook
  38. > Computer Science Department
  39. > University of Massachusetts
  40. > Amherst, MA 01003
  41.  
  42. Nope, you can't use fseek to increase the size of a file; thus, SEEK_END
  43. is only useful with an offset that is less than or equal to zero.  To
  44. set the size of a file, use ioctl with the FIOSETEOF selector.  This is
  45. described on page 125 of the MPW C 3.1 reference.
  46.  
  47. Enjoy,
  48. Tim Dierks
  49. MacDTS pinball addict
  50.