TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: John Gardeniers
from: Frank Adam
date: 1996-04-04 16:25:00
subject: Filename Expansion

G'Day John,
 
-=> Quoting John Gardeniers to Frank Adam <=-
It did get here after all, but took it's time.

 JG> All constructive criticism, sugestions  and comments are
 JG> welcome. Insults are best kept to yourself.
Ok :)

 JG> #define MAXPATH 160 /* Gives it plenty of room */
Dos allows 67 chars plus the filename so yes, you're a wasteful person,
 but i'll keep it to myself :)
                           
 JG> if(argc>3)
 JG> mode=atoi(argv[3]); /* 0 = Copy, 1 = Move, 2 = Rename */
Maybe an "if(mode  2) user_idiot();" after the
previous line 
would speed up things on error here, there is no reason to go any further 
into the program if it is TRUE.
Unless i missed it default to something somewhere else ?  

This is only esthetics, but lately i've been putting most of my error messgs 
in a separate function under a switch, and #define all possible errors.
Looks nice that way, and not any harder to follow, of course the defines are 
meaningful.
On error i just call errs(erno) or warns(warno).
On fatals i even stick an exit(int) in there, makes returning various 
errorlevels to batches an easy task.
Just thought i'll share that one :-)

 JG> /* Convert source & destination to upper case */
 JG> for(cnt=0; cnt src[cnt]=toupper(src[cnt]);

 JG> for(cnt=0; cnt dst[cnt]=toupper(dst[cnt]);
Hmm, strlen() in a loop is not very efficient, try this:

char *ptr1 = dst;
while(*ptr1 != '\0') *ptr1++ = toupper(*ptr1);
and the same for src.

 JG> {
 JG> puts("File cannot be copied to itself!\n");
I would do this check at the validate_dest routine, and abort from there..


  L8r Frank (fadam{at}ozemail.com.au).
                   
___ Blue Wave/DOS v2.21

--- Maximus 3.01
* Origin: The Software Parlour (3:635/544)
SEEN-BY: 50/99 78/0 620/243 623/630 632/349 635/503 544 727 711/401 409 410
SEEN-BY: 711/413 430 808 809 932 934 712/515 713/888 714/906 800/1 7877/2809
@PATH: 635/544 50/99 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.