home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!darwin.sura.net!uvaarpa!adastra!mbs
- From: mbs@adastra.cvl.va.us (Michael B. Smith)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: Determining file length
- Distribution: world
- Message-ID: <mbs.108r@adastra.cvl.va.us>
- X-NewsSoftware: GRn 1.16f (beta) by Mike Schwartz & Michael B. Smith
- Date: 14 Sep 92 19:38:28 EDT
- Organization: Private UUCP Node
- Lines: 35
-
- In article <1992Sep14.152206.28572@cs.uow.edu.au> u9147063@cs.uow.edu.au (Richard Barry Ling) writes:
- > 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?
-
- How about:
-
- int main (int argc, char **argv)
- {
- if (argc == 2) {
- BPTR fh = Open (argv [1], MODE_OLDFILE);
- int size;
- void *v = NULL;
-
- if (fh) {
- Seek (fh, 0, OFFSET_END);
- size = Seek (fh, 0, OFFSET_BEGINNING);
- if (v = AllocVec (size)) {
- Read (fh, v, size);
- ...
- FreeVec (v);
- }
- Close (fh);
- ...
- }
- }
- return 0;
- }
-
- --
- // Michael B. Smith
- \X/ mbs@adastra.cvl.va.us -or- uunet.uu.net!virginia.edu!adastra!mbs
-