home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!munnari.oz.au!yoyo.aarnet.edu.au!huon.itd.adelaide.edu.au!sirius.ucs.adelaide.edu.au!jpotter
- From: jpotter@sirius.ucs.adelaide.edu.au (Jonathan Potter)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: Determining file length
- Message-ID: <193odnINN6jk@huon.itd.adelaide.edu.au>
- Date: 15 Sep 92 04:22:15 GMT
- References: <1992Sep14.152206.28572@cs.uow.edu.au>
- Organization: Information Technology Division, The University of Adelaide, AUSTRALIA
- Lines: 32
- NNTP-Posting-Host: sirius.itd.adelaide.edu.au
-
- In article <1992Sep14.152206.28572@cs.uow.edu.au> u9147063@cs.uow.edu.au (Richard Barry Ling) writes:
- >
- >Suppose I want to take a filename from the command line, get the size of the
- >file, allocate an exact-size buffer, and read the file into the buffer...
- >(this is, in fact, exactly what I want to do...)
- >
- >Is there a better way to find file length in assembly language than to do a
- >Lock() on the file, allocate a half-k buffer or so for the crap Examine()
- >returns (I only want one long word of it :-(... ) pass that to Examine,
- >extract the file length, free the Examine() buffer, unlock the file... it's
- >screenfulls of code and an utter kludge. Can the file length be found in the
- >file structure you get from Open() or something?
-
- You can get the file size like this :
-
- file = Open (filename, MODE_OLDFILE) ;
-
- Seek (file, 0, OFFSET_END) ;
- size=Seek (file, 0, OFFSET_BEGINNING) ;
-
-
- Although its fairly slow, and also doesn't seem to work on vd0: (asdg's
- rrd, not that that should be a problem), it is usable.
-
- Jon
-
-
- --
- | Jonathan Potter | | A |
- | P.O. Box 289 | jpotter@itd.adelaide.edu.au | Suffusion |
- | Goodwood, SA | FidoNet : 3:680/829 | Of |
- | Australia 5034 | | Yellow |
-