Beispiel #1
0
void createTestFiles(void)
{
    Dsetdrv(drive);             // switch to selected drive
    Dsetpath("\\");
    (void) Dcreate("TESTDIR");
    Dsetpath("\\TESTDIR");

    int i, f;
    char numString[8];
    char fileName[16];
    for(i=0; i<25; i++) {
        byteToHex(i + 1, numString);
        
        strcpy(fileName, "FILE_");
        strcat(fileName, numString);
        f = Fcreate(fileName, 0);
        Fwrite(f, 7, fileName);
        Fclose(f);
        
        strcpy(fileName, "FILENAME.X");
        strcat(fileName, numString);
        f = Fcreate(fileName, 0);
        Fwrite(f, 12, fileName);
        Fclose(f);
        
        strcpy(fileName, "DIR_");
        strcat(fileName, numString);
        (void) Dcreate(fileName);
    }
}
Beispiel #2
0
int x_mkdir(const char *path)
{
#if USE_gemdos
	return xerror((int) gemdos(57, path));
#else
	return xerror(Dcreate(path));
#endif
}
Beispiel #3
0
WORD
created( char *dir )
{
	int 	ret;
	char	*ptr;

	updatbox(dir);
rechkd2: 				/* update check the dir existing or not */
	switch( chkdf( dir, CPDIR ) )	
	{
	  case	QUIT:
	  	f_abort = 1;
	  	return(FALSE);	  
	  case	SKIP:
		return(SKIP);
	  case	FALSE:
		return(FALSE);
	  case 	CHECK:
	 	goto 	rechkd2;
	  case	OK:	
repeat:		
	  	if (Dcreate(fixdst))	
	  	{
	  	  if ( write_save )
	  	    goto ll_1;
						/* retry	*/
		  if ( ( ret = fill_string( fixdst, CNTCRTDR ) ) == 2 )
		    goto repeat;
		  else if (ret == 3)		/* abort */
		    { 			
		      f_abort = 1;
		      return(FALSE);
		    }
		}

		if ( opcode == OP_MOVE )
		{				/* fixsrc -> C:\XXX\ */
		  ptr = r_slash( fixsrc );
		  *ptr = 0;
		  upfdesk( fixsrc, fixdst );
		  *ptr = '\\'; 
		}
		
		break;	/* default */
	}
ll_1:			/* update the number of dir */
	updatnum(NUMDIR, --numdirs);
	return(TRUE);
}
Beispiel #4
0
/****************************************************************
*																*
*			test la chaŒne renvoy‚e par scrp_read()				*
*																*
****************************************************************/
boolean test_scrap_path(char *scrap_path)
{
	int len = (int)strlen(scrap_path);

	if (len == 0)
	{
		int device, err;

		/* C:\ existe ? */
		if (Drvmap() & (1<<2))
			device = 'C';
		else
			device = 'A';

		sprintf(scrap_path, "%c:\\CLIPBRD", device);

		/* cr‚e le r‚pertoire */
		if ((err = Dcreate(scrap_path)) < 0 && err != -36)
		{
			error_msg(err);
			return TRUE;
		}

		strcat(scrap_path, "\\");

		/* on pr‚vient l'AES */
		if (!scrp_write(scrap_path))
		{
			error_msg(Z_CLIPBOARD_NOT_INSTALLABLE);
			return TRUE;
		}
	}
	else
		if (scrap_path[len-1] != '\\')
		{
			if (Fsfirst(scrap_path, FA_SUBDIR))
			{
				/* c'est un r‚pertoire sans \ … la fin (C:\CLIPBRD) */
				scrap_path[len] = '\\';
				scrap_path[len+1] = '\0';
			}
			else
				/* c'est pas un r‚pertoire (C:\CLIPBRD\SCRAP.TXT) */
				*(strrchr(scrap_path, '\\')+1) = '\0';
		}

	return FALSE;
} /* test_scrap_path */
Beispiel #5
0
int Run_through_dir(DIR *entry, int nbr_of_entries, 
                    drive_struct *str, int *seq_in,
                    int *ch_sum_in, int *is_v_in,
                    char *my_path_end,
                    char *long_path_end)
{
 /* run through the dir copy files as it goes */

 /* my_dir_end points to end of current path */ 
 int expected_seq=*seq_in;  /* 0 means tos name slot */
 int last_check_sum=*ch_sum_in;
 int is_vfat_slot=*is_v_in;


 for(;nbr_of_entries>0;nbr_of_entries--,entry++,expected_seq--)
 {
  VDIR *vfat_slot=entry;
  /* is this an extended slot?? */
  
  if((vfat_slot->attr==0xf)&&
     (!vfat_slot->reserved)&&
     (!vfat_slot->first_cluster[0])&&
     (!vfat_slot->first_cluster[1]))
  {
   /* if last bumb expected seq and checksum */
   if (vfat_slot->id&0x40)
   {
    expected_seq=vfat_slot->id&0x3f;
    if (expected_seq<(LONG_FILE_LENGTH/13))
     long_file_name[expected_seq*13]=0; /* always terminate filename */

    last_check_sum=vfat_slot->alias_checksum;
    is_vfat_slot=TRUE;
   }
   /* check if checksum and sequence are
      correct */
   
   if (((vfat_slot->id&0x3f)==expected_seq)&&
       (vfat_slot->alias_checksum==last_check_sum)&&
       (expected_seq<(LONG_FILE_LENGTH/13)))
   {
    /* slot ok! copy filename */
    /* use the sequence number to index into the
       file name */
    char *name=long_file_name+(expected_seq-1)*13;

    /* so a simple conversion from unicode */
    /* will work on all ASCII characters */

    *name++=vfat_slot->name0_4[0];
    *name++=vfat_slot->name0_4[2];
    *name++=vfat_slot->name0_4[4];
    *name++=vfat_slot->name0_4[6];
    *name++=vfat_slot->name0_4[8]; 

    *name++=vfat_slot->name5_10[0]; 
    *name++=vfat_slot->name5_10[2]; 
    *name++=vfat_slot->name5_10[4]; 
    *name++=vfat_slot->name5_10[6]; 
    *name++=vfat_slot->name5_10[8]; 
    *name++=vfat_slot->name5_10[10]; 

    *name++=vfat_slot->name11_12[0]; 
    *name++=vfat_slot->name11_12[2]; /* that's it! 13 characters.. */ 
   }
   else
   {
    /* vfat corrupt */
    is_vfat_slot=FALSE;
   }
  }
  else
  {
   /* should it be the "tos" slot?? */
   if (expected_seq!=0)
    is_vfat_slot=FALSE;

   /* check if valid "tos" slot */

   /* DEBUG print! */
   if (is_vfat_slot)
    printf("file name found: %s\n",long_file_name);

   /* if valid copy file or create dir and descend */
   
   if((entry->attr!=0xf)&&
     (entry->first_cluster[0]|
      entry->first_cluster[1])&&
     (is_vfat_slot))
   {
    long cluster=(entry->first_cluster[1]<<8)|entry->first_cluster[0];
    unsigned char sum;
    int  i;
    char *ptr=entry->name;
    char *curr_tos_end=my_path_end;
 
    /* calc filename checksum */

    sum=i=0;
    for(;i<8;)
    {
     unsigned char ch=entry->name[i];
     sum=((((sum&1)<<7)|((sum&0xfe)>>1))+ch);

     if ((ch!=0)&&(ch!=' '))
     {
      *curr_tos_end++=ch;
     }
     i++;
    }

    *curr_tos_end++='.';

	i=0;
    for(;i<3;)
    {
     unsigned char ch=entry->name[8+i];
     sum=((((sum&1)<<7)|((sum&0xfe)>>1))+ch);

     if ((ch!=0)&&(ch!=' '))
     {
      *curr_tos_end++=ch;
     }
     i++;
    }

    if (*(curr_tos_end-1)=='.')
    {
     curr_tos_end--;
    }
    
    *curr_tos_end=0;
 
    
    if ((cluster>=2)&&(cluster<=0xfef)&&(last_check_sum==sum))
    {
     char *l_p;

     strcpy(long_path_end,long_file_name);

     printf("VFAT file path: %s\n",long_path);
     printf("tos file path: %s\n",tos_path);



     /* file is ok */
     if (entry->attr&0x10)
     {
      int seq=-1;
      int cs=0;
      int flag=FALSE;

      int  cluster_size=str->bpb->clsiz;
      char *cluster_buff=malloc(str->bpb->recsiz*str->bpb->clsiz);
      unsigned long cluster;

      if (!cluster_buff)
       return(FALSE);


      *curr_tos_end++='\\';
      l_p=long_path_end+strlen(long_path_end);

      /* directory.. create and descend! */
      printf("descending!\n");
      
      /* create dir on target */
      Dcreate(long_path);
      /* descend */

      *l_p++='\\';
      *l_p=0;

      cluster=(entry->first_cluster[1]<<8)|entry->first_cluster[0];

      do
      {
       Rwabs(0,cluster_buff,cluster_size,
             cluster_size*(cluster-2)+str->bpb->datrec,
             str->drive);              


       Run_through_dir(cluster_buff,str->bpb->recsiz*
                       cluster_size/sizeof(DIR),str,&seq,
                       &cs,&flag,curr_tos_end,l_p);

       cluster=Next_cluster(str,cluster);
      } while(cluster);
   
      free(cluster_buff);

	  printf("ascending\n");

      /* return */
      
     }
     else
     {
      /* normal file.. copy! */
      printf("normal file!\n");

      /* make dos name */

      if (!Copy_file(tos_path,long_path,entry->attr))
      {
       return(FALSE);
      }
     }
    }
   }
   /* if not ignore */
  }
 }
Beispiel #6
0
int
doact( VOID )
{
/*	char 		*saved; */
	DMABUFFER 	*dumb, * saved;
	REG int 	ret, retmsg;
	int		error;

	if ( f_level >= ( COPYMAXDEPTH + 1 ) )
	{
act_1:	  do1_alert( STFO8DEE );
	  return( FALSE );
	}
	/* changed CHAR * to DMABUFFER * in expression below - JTT */
	if ( !( dumb = (DMABUFFER *)malloc( (LONG)sizeof( DMABUFFER ) ) ) )
	  goto act_1; 
	
	f_level++;
	retmsg = TRUE;
	saved = (DMABUFFER *)Fgetdta();
	Fsetdta( dumb );
	strcat(getall, fixsrc);

	if ( !( error = Fsfirst(fixsrc, 0x37) ) )	
	{
	  do
	  {
	    if ( !ch_undo( ) || f_cancel )	/* user want to abort	*/
	    {
	      f_abort = 1;
	      retmsg = FALSE;
	      goto mvend;
	    } 

	    if (dumb->d_fname[0] != HOME)	
	    {
	      if (SUBDIR & dumb->d_fattr)	
	      {
		chkbuf(srclen, srcbuf, &fixsrc);	/* check buf size */
		addfile(fixsrc, dumb->d_fname); /* add a dir into the path */
		strcat(bckslsh, fixsrc);
		if (opcode != OP_DELETE)
		{
		  chkbuf(dstlen, dstbuf, &fixdst);	/* check buf size */
		  strcat(dumb->d_fname, fixdst);
		}
		else
		  goto dorec;

		updatbox(dumb->d_fname);
rechkd1: 						/* update check the dir existing or not */
		switch( chkdf( dumb->d_fname, CPDIR ) ) 
		{
		  case	QUIT:
		  	f_abort = 1;
		  	retmsg = FALSE;
		  	goto mvend;

		  case	SKIP:
		  	backdir(fixsrc);
		  	backdir(fixdst);
		  	updatnum(NUMDIR, --numdirs);
		  	srclen -= FILE_LEN;		/* subtract the add lenth */
		  	dstlen -= FILE_LEN;		/* subtract the add lenth */
		  	retmsg = TRUE;
		  	continue;

		  case 	FALSE:
		  	goto mvend;

		  case 	CHECK:
		 	goto rechkd1;

		  case 	OK:
recrtd:		  	
			if (Dcreate(fixdst))	
		  	{
		  	  if ( write_save )
	      	            goto kk_1;

			  switch( fill_string( fixdst, CNTCRTDR ) )
		  	  {	
			    case 1:			/* skip */
		  	      backdir(fixsrc);
		  	      backdir(fixdst);
		  	      updatnum(NUMDIR, --numdirs);
		  	      srclen -= FILE_LEN;	/* subtract the add lenth */
		  	      dstlen -= FILE_LEN;	/* subtract the add lenth */
		  	      continue;

			    case 2:		/* retry */
		  	      goto recrtd;
		
			    default: 		/* quit */
		  	      f_abort = 1;
		  	      retmsg = FALSE;
		  	      goto mvend;

		  	  }/* switch */
		  	}/* if recrtd */

			break;
		}
kk_1:
		updatnum(NUMDIR, --numdirs);
		strcat(bckslsh, fixdst);
dorec:
		if (!doact())	 /* do the recursion */
		{
		  retmsg = FALSE;
		  goto mvend;
		}

		if (opcode == OP_COPY)
		  goto clndir;

		rmstarb(fixsrc);		/* after call, -> c:\d1\ */

		if (opcode == OP_DELETE)
		{
		  getlastpath(filestr, fixsrc);
		  updatbox(filestr);
		}
remvd:
		if (Ddelete(fixsrc))	
		{ 				/* delete a dir */
		  if ( ( ret = fill_string( fixsrc, CNTDELD ) ) == 2 )
		    goto remvd; 		/* retry */

		  else if (ret == 3)
		  { 				/* abort */
		    f_abort = 1;
		    retmsg = FALSE;
		    goto mvend;
		  }
	 	}
		else				/* No error	*/
		  upfdesk( fixsrc, (BYTE*)0 );

clndir:
		backdir(fixsrc);		/* back one dir */
		srclen -= FILE_LEN;		/* subtract the add lenth */
		if (opcode == OP_DELETE)
		  updatnum(NUMDIR, --numdirs);
		else
		{
		  backdir(fixdst);		/* back one dir */
		  dstlen -= FILE_LEN;		/* subtract the add lenth */
		}
	    } 
	    else 
	    {
		getlastpath(filestr, fixdst);
		updatname(CPDIR, filestr);		/* update the dir */
		updatname( CPFILE, dumb->d_fname ); 	/* update the file */
		chkbuf(srclen, srcbuf, &fixsrc);	/* check buf size */
		addfile(fixsrc, dumb->d_fname);
		if (opcode != OP_DELETE)
		{
		  chkbuf(dstlen, dstbuf, &fixdst);	/* check buf size */
		  addfile(fixdst, dumb->d_fname);
		  rename = 0;
		  if (!(retmsg = wrfile(dumb->d_fname)))
		    goto mvend;

		  if ((rename) || (retmsg == SKIP))
		    goto clnfile;
		}

		if (opcode == OP_COPY)
		  goto clnfile;
remvf:
		if (ret = (WORD)(Fdelete(fixsrc))) 	/* rm the file from source */
		{			/* seek error or drive not ready */
/*		  if ((ret == E_SEEK) || (ret == EDRVNR))
		  {
		    retmsg = FALSE;
		    goto mvend;
		  }
*/					/* retry */
	          if ( ( ret = fill_string( fixsrc, CNTDELF ) ) == 2 )
		    goto remvf;
		  else 
		  if ( ret == 3 )	
		  {			/* abort */
		    f_abort = 1;
		    retmsg = FALSE;
		    goto mvend;
		  }
		}
		else
		  upfdesk( fixsrc, (BYTE*)0 );
clnfile:
		backdir(fixsrc);		/* back one dir */
		srclen -= FILE_LEN;		/* subtract the add lenth */
		if (opcode == OP_DELETE)
		  updatnum(NUMFILE, --numfiles);
		else
		{
		  backdir(fixdst);		/* back one dir */
		  dstlen -= FILE_LEN;		/* subtract the add lenth */
		}
	      }
	    } 
	  } while (!Fsnext());
	}
	else 
	{
	  if ( error != EFILNF )	/* if not file not found */
	    retmsg = FALSE;		/* then return error	 */
	}
	
mvend:
	Fsetdta( saved );
	f_level--;
	free( dumb );	
	return( retmsg );
}
Beispiel #7
0
copy_dir ()       /* source und dest sind global; bei Fehler: return (1) */
{
int source_len, dest_len, fd_source, fd_dest, error;
char dta[44];
long old_dta, fail, size, count;
   error=0;
   source_len=strlen(source);
   dest_len=strlen(dest);
   old_dta=Fgetdta();
   Fsetdta(dta);
   strcat(source,"\\*.*");
   fail=Fsfirst(source,16);
   source[source_len]=0;
   while (!fail)
   {  strcat(source,"\\");
      strcat(source,dta+30);
      strcat(dest,"\\");
      strcat(dest,dta+30);
      if (dta[21]==16)         /* Directory */
      {  if (strcmp(dta+30,".")&&strcmp(dta+30,".."))
            if (Dcreate(dest))
            {  printf("Ordner %s l„žt sich nicht anlegen.\n",dest);
               error=1;
            }
            else
               error|=copy_dir(source,dest);
      }
      else                     /* File */
      {  printf("%s  nach  %s\n",source,dest);
         if ((fd_source=Fopen(source,0))<0)
         {  printf("Datei %s l„žt sich nicht ”ffnen.\n",source);
            error=1;
         }
         else
            if ((fd_dest=Fcreate(dest,dta[21]&~1))<0)
            {  printf("Datei %s l„žt sich nicht einrichten.\n",dest);
               error=1;
            }
            else
            {  size=*(long*)(dta+26);
               while (size)
               {  count=(size<buf_size)?size:buf_size;
                  size-=count;
                  if (Fread(fd_source,count,buffer)!=count)
                  {  printf("Fehler beim Lesen von %s .\n",source);
                     error=1;
                     break;
                  }
                  if (Fwrite(fd_dest,count,buffer)!=count)
                  {  printf("Fehler beim Schreiben von %s .\n",dest);
                     error=1;
                     break;
                  }
               }
               Fclose(fd_source);
               Fclose(fd_dest);
               fd_dest=Fopen(dest,1);
               Fdatime(fd_dest,dta+22,1);
               Fclose(fd_dest);
            }
      }
      source[source_len]=0;
      dest[dest_len]=0;
      fail=Fsnext();
   }
   if (fail!=-49l)
   {  printf("Ordner %s nicht gefunden.\n",source);
      error=1;
   }
   Fsetdta(old_dta);
   return (error);
}