home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sys / amiga / programm / 13366 < prev    next >
Encoding:
Internet Message Format  |  1992-09-14  |  1.8 KB

  1. Path: sparky!uunet!munnari.oz.au!yoyo.aarnet.edu.au!huon.itd.adelaide.edu.au!sirius.ucs.adelaide.edu.au!jpotter
  2. From: jpotter@sirius.ucs.adelaide.edu.au (Jonathan Potter)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: Determining file length
  5. Message-ID: <193odnINN6jk@huon.itd.adelaide.edu.au>
  6. Date: 15 Sep 92 04:22:15 GMT
  7. References: <1992Sep14.152206.28572@cs.uow.edu.au>
  8. Organization: Information Technology Division, The University of Adelaide, AUSTRALIA
  9. Lines: 32
  10. NNTP-Posting-Host: sirius.itd.adelaide.edu.au
  11.  
  12. In article <1992Sep14.152206.28572@cs.uow.edu.au> u9147063@cs.uow.edu.au (Richard Barry Ling) writes:
  13. >
  14. >Suppose I want to take a filename from the command line, get the size of the
  15. >file, allocate an exact-size buffer, and read the file into the buffer...
  16. >(this is, in fact, exactly what I want to do...)
  17. >
  18. >Is there a better way to find file length in assembly language than to do a
  19. >Lock() on the file, allocate a half-k buffer or so for the crap Examine()
  20. >returns (I only want one long word of it :-(... ) pass that to Examine,
  21. >extract the file length, free the Examine() buffer, unlock the file... it's
  22. >screenfulls of code and an utter kludge. Can the file length be found in the
  23. >file structure you get from Open() or something?
  24.  
  25. You can get the file size like this :
  26.  
  27. file = Open (filename, MODE_OLDFILE) ;
  28.  
  29. Seek (file, 0, OFFSET_END) ;
  30. size=Seek (file, 0, OFFSET_BEGINNING) ;
  31.  
  32.  
  33. Although its fairly slow, and also doesn't seem to work on vd0: (asdg's
  34. rrd, not that that should be a problem), it is usable.
  35.  
  36. Jon
  37.  
  38.  
  39. -- 
  40. | Jonathan Potter |                              | A                       |
  41. | P.O. Box 289    | jpotter@itd.adelaide.edu.au  |   Suffusion             |
  42. | Goodwood, SA    | FidoNet : 3:680/829          |               Of        |
  43. | Australia  5034 |                              |                  Yellow |
  44.