From: | Stephen Illingworth |
Date: | 10 Aug 2001 at 22:27:25 |
Subject: | [amiga-c] Re: How do I copy clone |
Hello Twelvebullets
On 10-Aug-01, you wrote:
>
> Heres a clone example,
>
> Set Source to a source file to read
> Set Dest to a file to write to
>
> Copies Size (100) bytes
> and sets date/protection
>
> feel free to use and abuse it
Looks good :-)
However, don't do this
fibb = (struct FileInfoBlock*) AllocVec(sizeof (struct FileInfoBlock), MEMF_PUBLIC);
it might work but it's wrong and will almost certainly bite you
or somebody else on the arse sooner or later. Use
AllocDosObject() instead. For example,
fibb = (struct FileInfoBlock *) AllocDosObject (DOS_FIB, NULL);
and freeing it with
FreeDosObject (DOS_FIBB, fibb);
Just one more tip. At the end of main you return a value of 1.
You should really return 0.
A value of 1 indicates to the host system a failure of some sort where-as
0 indicates success. Normally this isn't a problem, but if you use this
program in a script for example, and the script's author had done
FAILAT 1
before he called your program, then the script would fail even though
it should have succeeded. Not a very likely scenario I admit, but something
worth thinking about.
An alternative to returning 0 is return EXIT_SUCCESS (which is defined to be
0). This is an ANSI convention and is defined in stdlib.h.
Regards
Steve
PS. I thought you said you were using DICE? I'm pretty sure DICE
doesn't compile C++ code and I'm certain it doesn't compile C99
code. So how can you get away with declaring the FileInfoBlock
pointer in the middle of a code block?
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Small business owners...
Tell us what you think!
http://us.click.yahoo.com/vO1FAB/txzCAA/ySSFAA/dpFolB/TM
---------------------------------------------------------------------~->
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/