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

  1. Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!darwin.sura.net!uvaarpa!adastra!mbs
  2. From: mbs@adastra.cvl.va.us (Michael B. Smith)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: Determining file length
  5. Distribution: world
  6. Message-ID: <mbs.108r@adastra.cvl.va.us>
  7. X-NewsSoftware: GRn 1.16f (beta) by Mike Schwartz & Michael B. Smith
  8. Date: 14 Sep 92 19:38:28 EDT
  9. Organization: Private UUCP Node
  10. Lines: 35
  11.  
  12. In article <1992Sep14.152206.28572@cs.uow.edu.au> u9147063@cs.uow.edu.au (Richard Barry Ling) writes:
  13. > Is there a better way to find file length in assembly language than to do a
  14. > Lock() on the file, allocate a half-k buffer or so for the crap Examine()
  15. > returns (I only want one long word of it :-(... ) pass that to Examine,
  16. > extract the file length, free the Examine() buffer, unlock the file... it's
  17. > screenfulls of code and an utter kludge. Can the file length be found in the
  18. > file structure you get from Open() or something?
  19.  
  20. How about:
  21.  
  22. int main (int argc, char **argv)
  23. {
  24.         if (argc == 2) {
  25.                 BPTR fh = Open (argv [1], MODE_OLDFILE);
  26.                 int size;
  27.                 void *v = NULL;
  28.  
  29.                 if (fh) {
  30.                         Seek (fh, 0, OFFSET_END);
  31.                         size = Seek (fh, 0, OFFSET_BEGINNING);
  32.                         if (v = AllocVec (size)) {
  33.                                 Read (fh, v, size);
  34.                                 ...
  35.                                 FreeVec (v);
  36.                         }
  37.                         Close (fh);
  38.                         ...
  39.                 }
  40.         }
  41.         return 0;
  42. }
  43.  
  44. --
  45.   //   Michael B. Smith
  46. \X/    mbs@adastra.cvl.va.us  -or-  uunet.uu.net!virginia.edu!adastra!mbs
  47.