Category : C Source Code
Archive   : JAZLIB.ZIP
Filename : JZCPYFIL.C

 
Output of file : JZCPYFIL.C contained in archive : JAZLIB.ZIP

/*
ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
³jzcpyfil.c ³
³Copy a file (wild cards are ok) ³
³ ³
³synopsis ³
³ werr = jzcpyfil("\\jaz\\*.*","a:\"); ³
³ ³
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
*/

#include
#include

#define SIZE 32767

jzcpyfil(fsource,fdestin)
char *fsource;
char *fdestin;
{
int wsource,wdestin;
int wnum;
TDIR wdir;
int werr,wpos;
int w;
char wspath[65],wdpath[65]; /* source and destin path names */
char wtemp[65];
char *wbuf,*malloc();

if ( (wbuf = malloc(SIZE)) == 0 ) {
printf("\Out of memory for copy, Aborting...");
exit(255);
}

strcpy(wspath,fsource);
strcpy(wdpath,fdestin);

for (w = strlen(wspath) - 1 ; w >= 0 ; w --) /* parse out path */
if (wspath[w] == '\\')
break;

if (w >= 0)
wspath[w+1] = 0; /* hold only the path */
else
*wspath = 0; /* Null path string */

w = strlen(wdpath) - 1;

if (index("?*:",*(wdpath+w)) != -1 ) {
for ( ; w >= 0 ; w --)
if ((index("\\:",*(wdpath+w))) != -1)
break;
*(wdpath+w+1) = 0;
}
else
strcat(wdpath,"\\");

#if DEBUG
printf("\nsource: %s",wspath);
printf("\ndestin: %s",wdpath);
#endif
/**
** Here's where we search the directory
**/

werr = jzfndfst(fsource,32,&wdir); /* find first matching file */

if (werr == 0) /* perform directory search */
do {
strcpy(wtemp,wspath); /* get source path into wtemp */
strcat(wtemp,wdir.name); /* get full source path name */
wsource = jzopnfil(wtemp,0); /* open for read only */
strcpy(wtemp,wdpath); /* get destin path into wtemp */
strcat(wtemp,wdir.name); /* get full destin path name */
wdestin = jzcrtfil(wtemp,0); /* create file normal attribute */
printf("\n%s",wdir.name);

/**
** Here's where we copy the file.
**/

do {
wnum = jzredfil(wsource,wbuf,SIZE); /* request SIZE bytes to read */
if (wnum)
jzwrtfil(wdestin,wbuf,wnum); /* write only num read */
} while (wnum);

jzclsfil(wdestin);
jzclsfil(wsource);

werr = jzfndnxt(&wdir); /* get next item */
} while (werr == 0);
else
printf("\Not Found");
}


  3 Responses to “Category : C Source Code
Archive   : JAZLIB.ZIP
Filename : JZCPYFIL.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/