Category : OS/2 Files
Archive   : OS2MOVE.ZIP
Filename : MOVE.C

 
Output of file : MOVE.C contained in archive : OS2MOVE.ZIP

/*
* "MOVE.c" A quick and dirty move utility for OS/2. *
* *
* This program was written as an excercise in C and OS/2 *
* *
* This program demonstrait using 3 File functions under OS/2 *
* *
* DosFindFirst *
* DosFindNext *
* DosMove *
* *
* Uploaded for Public Domain *
* *
* Enjoy..... *
* *
* Tareq AboAlfaraj *
* */



#define INCL_DOSFILEMGR
#include
#include
#include
#include


int expand_arg(char *, char **,int *,char *);

void main(int argc, char **argv)
{
int i;
char *from,*to;
char message[80];
char source[80];
char src[80];
char destin[80];
char dest[80];
char *arg[100];
int count;


if(argc==1) {
puts("usage MOVE [path]filename [new path]\n\n"
"Wild Characters are allowed in file name");
return;}
argc--;
if(expand_arg(argv[1],arg,&count,source)){
puts("Error ... File not found ....\n");
exit(-1);
}
if(argc!=1){
strcpy(destin,argv[argc]);
to=strrchr(destin,'\0');
to--;
if(*to!='\\')
strcat(destin,"\\");
}

for(i=0;i strcpy(dest,destin);
strcpy(src,source);
to=strcat(dest,arg[i]);
from=strcat(src,arg[i]);
strcpy(message,"file ");
strcat(message,from);
if(DosMove(from,to,0))
strcat(message," not moved to ");
else
strcat(message," moved to ");
strcat(message,to);
puts(message);
}
exit(0);}

int expand_arg(char * name, char * exp_names[], int * argc, char *path)
{
FILEFINDBUF buffer;
int i=0;
int n;
char *pntr,*p;
unsigned handel=0xffff,count=1;

if((pntr=strrchr(name,'\\'))!=NULL){
p=name;
for(n=1;p++!=pntr;n++);
strncpy(path,name,n);}
else if((pntr=strrchr(name,':'))!=NULL){
p=name;
for(n=1;p++!=pntr;n++);
strncpy(path,name,n);}
else
strcpy(path,"");
if(DosFindFirst(name,&handel,0x00,&buffer,sizeof(buffer),&count,0)) return(-1) ;
*argc=i+1;
exp_names[0]=malloc(13);
strcpy(exp_names[0],buffer.achName);
for(;;){
if(DosFindNext(handel,&buffer,sizeof(buffer),&count)) return(0);
exp_names[++i]=(char *) malloc(13);
strcpy(exp_names[i],buffer.achName);
*argc=i+1;
}}







  3 Responses to “Category : OS/2 Files
Archive   : OS2MOVE.ZIP
Filename : MOVE.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/