Exemplo n.º 1
0
/* Unidad destino */
void pedir_unidad(void)
{
	int a;
	FILE *archivo;

	ventana(10,10,70,15);
	centrar("Unidad destino:", 12);
	textbackground(BLACK);
	textcolor(LIGHTGRAY);
	centrar("    ", 13);
	gotoxy(39, 13);
	_setcursortype(_NORMALCURSOR);
	unidad_destino = getch();
	_setcursortype(_NOCURSOR);
	gotoxy(39, 13); cprintf("%c:", toupper(unidad_destino));
	delay(200);
	unidad_destino = toupper(unidad_destino) - 'A';
	textcolor(WHITE);
	textbackground(LIGHTGRAY);
	centrar("Verificando unidad_destino destino...", 12);
	setdisk(unidad_destino);
	gotoxy(38, 13); cprintf(" %c: ", toupper(unidad_destino + 'A'));
	for(a = 0; a < 40; a++) {
		if((archivo = fopen("6DPAS666.666", "wt")) == NULL) {
			error("Error al intentar leer la unidad_destino.");
		}
		putc(1, archivo);
		fclose(archivo);
		remove("6DPAS666.666");
	}
	setdisk(unidad_actual);
}
Exemplo n.º 2
0
main (int argc, char * argv[])
{
      int d;
      int max_d;

      char wk_str[128];

      if (argc > 1)
      {
            strupr (argv[1]);
            if (argv[1][1] == ':')
            {
                  /*
                  ** Find out what the maximum drive number can be.
                  */

                  max_d = getdisk ();
                  max_d = setdisk (max_d);

                  d = argv[1][0] - 'A';
                  if (d < max_d)
                  {
                        /*
                        ** If the drive specification was valid position
                        ** to it and then do a change directory.
                        */

                        setdisk (d);
                        chdir (argv[1]);
                  }
                  else
                  {
                        puts ("Invalid drive specification");
                        return -1;
                  }
            }
            else
            {
                  /*
                  ** If the argument has no drive spec just do a regular
                  ** change directory.
                  */

                  chdir (argv[1]);
            }
      }
      else
      {
            /*
            ** If no arguments are passed, return the current working
            ** directory path just like MSDOS cd does.
            */

            puts (getcwd (wk_str, sizeof (wk_str)));
      }
      return 0;
}
Exemplo n.º 3
0
int CLY_getcurdir(int drive, char *buffer)
{
    if (!drive) getwd(buffer);
    else
    {
        int d = getdisk();
        setdisk(drive-1);
        getwd(buffer);
        setdisk(d);
    }
    strcpy(buffer,buffer+3);
    return 0;
}
Exemplo n.º 4
0
	int chddir(const char *dir)
	{
	  // assume: drive is full pathname.
	  int ch = toupper(dir[0]);
	  if (isalpha(ch)) setdisk(ch-'A');
	  return chdir(dir);
	}
Exemplo n.º 5
0
Arquivo: gpwin.c Projeto: elboza/EIDOS
main()
{
 strcpy(status.nomefile,"base.idl");
 inizializza();
 setmenuP(0," Files ",1,hh);
 setmenuP(0," Compile ",1,menuto2);
 setmenuP(0," Quit! ",1,esci);
 setmenuS(0,1," Ciao ",1,hh);
 setmenuS(0,1," Addio ",1,gg);
 gwindow(60,60,300,200," Main Win ",12,1,14,3);
 num=status.active_window;
 perc_init();
 for(x=0;x<=37;x++)
 {
  percent(x,37);
 }
 perc_end();
 mouse(1);
 while(kd!=27)
 {
  while((kd=ikey())==0) {}
  controlla(kd);
  x=contr_drives();
  if(x!=-1) {setdisk(x);dato=x;}
 }
 mouse(2);
 nogwin();
 finisci();
 return(0);
}
Exemplo n.º 6
0
/* Verifica el espacio disponible en el disco */
void verificar_espacio(void)
{
	int cont;
	FILE *archivo;
	long int tamano;

	dibujar_pantalla();
	for(cont = 0; cont < 500; cont++) {
		if((archivo = fopen("inst.dat", "rb")) == NULL) {
			error("Error al leer el disco origen.");
		}
		getc(archivo);
		fclose(archivo);
	}
	ventana(8,10,72,15);
	textcolor(BLACK);
	centrar("El programa de instalaci¢n esta verificando que", 12);
	centrar("haya espacio suficiente en el disco...", 13);

	setdisk(unidad_destino);
	if((archivo = fopen("6DPASoft.666", "wb")) == NULL) {
		error("Error al escribir en el disco destino.");
	}

	for(tamano = 0; tamano < 50000000; tamano++){
		putc(4, archivo);
		if (ferror(archivo)) {
			error("Espacio insuficiente en el disco.");
			fclose(archivo);
			remove("6DPASoft.666");
		}
	}
	fclose(archivo);
	remove("6DPASoft.666");
}
CLIPPER setdrive()
{
    if (! (PCOUNT==1 || ISNUM(1)))
        _retni(0);
    else
        _retni(setdisk(_parni(1)));
}
Exemplo n.º 8
0
VOID APIENTRY ThdDskPerf( ULONG ulTask )
{
  int k;
  PDTV pDisk;

  pDisk = (PDTV)ulTask;

  pDisk->szDir[ 6 ] = (char)( pDisk->ulTask + 0x30 );
  pDisk->szDir[ 7 ] = 0;

  setdisk( (int)( pDisk->szDrive[ 0 ] - 'A' ) );
  mkdir( pDisk->szDir );
  chdir( pDisk->szDir );

  /* create test files */
  DosPostEventSem( pDisk->hevReady );

  /* start timing */
  DosWaitEventSem( hevGo, SEM_INDEFINITE_WAIT );

  /* perform string of file operations */
  for( k = 0; k < ITER; k++ )
    readswrites( pDisk );

  /*stop timimg*/
  EndItAll( 0, pDisk );
}
Exemplo n.º 9
0
Arquivo: gvpmisc.c Projeto: 131/gsview
int 
gs_chdir(char *dirname)
{
int rc = 0;
	DosError(FERR_DISABLEHARDERR);
#ifdef __BORLANDC__
	if (isalpha(dirname[0]) && (dirname[1]==':'))
		(void) setdisk(toupper(dirname[0])-'A');
	if (!((strlen(dirname)==2) && isalpha(dirname[0]) && (dirname[1]==':')))
		chdir(dirname);
	rc = 1;
#else
#ifdef __IBMC__
	if (isalpha(dirname[0]) && (dirname[1]==':'))
	    if (_chdrive(toupper(dirname[0])-'A'+1))
		rc = -1;
	if (!rc && !((strlen(dirname)==2) && isalpha(dirname[0]) && (dirname[1]==':')))
	    rc = _chdir(dirname);
#else
	if (isalpha((int)(dirname[0])) && (dirname[1]==':'))
	    if (_chdrive(dirname[0]))
		rc = -1;
	rc = _chdir2(dirname);
#endif
#endif
	DosError(FERR_ENABLEHARDERR);
	return rc;
}
Exemplo n.º 10
0
int CheckDrive(int drive, char *msg) {
   int save, disk = toupper(drive)-'A';
   char s[81];
   save = getdisk();
   setdisk(disk);
   if (disk != getdisk()) {
      _setcursortype(_NOCURSOR);
      printf("%c", 7);
      sprintf(s, "%s...Press any key to continue...", msg);
      descr(s);
      getch();
      _setcursortype(_NORMALCURSOR);
      descr(NULL);
      return(2);
   }
   setdisk(save);
   return(1);
}
//----------------------------------
// Event EV_CBN_SELCHANGE for ID_DRIVES
//----------------------------------
void PrjPath::EvSelChangeDrives(void)
{
    char s[MAXPATHSIZE];
    m_Drives->GetSelString(s,sizeof(s));
    s[1] = NULL;
    setdisk(s[0] - 'A');
    getcwd(s,sizeof(s));
    PrettyPathFile(s);
    SetDlgItemText(ID_INFO,s);
    DoDirectories();
}
Exemplo n.º 12
0
int changeDrive(int drive)
{	drive = drvNum(drive);

    setdisk(drive);

    if (getdisk() == drive) 
    	return 0;

  displayString(TEXT_ERROR_INVALID_DRIVE, drive + 'A');

  return 1;
}
Exemplo n.º 13
0
int changeDrive(int drive)
{	drive = drvNum(drive);

    setdisk(drive);

    if (getdisk() == drive) 
    	return 0;

	error_invalid_drive(drive);

	return 1;
}
Exemplo n.º 14
0
void main(int Argc, char *Argv[])
{
 int i;
 int autre_entree;
 char lecteur[MAXDRIVE];
 char repertoire[MAXDIR];
 char nom_fichier[MAXFILE];
 char extension[MAXEXT];
 if(Argc==1)
 {
  printf("Syntaxe : GO <Lecteur>:<R‚pertoire>");
  exit(0);
 }
 else printf("Go Directory\n");
 niveau=1;
 autre_entree=1;
 strcpy(Argv[1],strupr(Argv[1]));
 fnsplit(Argv[1],lecteur,repertoire,nom_fichier,extension);
 strcpy(chemin_cours,lecteur);
 strcat(nom_fichier,extension);
 probleme=Init_repert();
 while(autre_entree)
 {
  if(!probleme && !autre_repert())
  {
   derniere_entree[niveau++]=entree_actuelle;
   strcat(chemin_cours,"\\");
   strcat(chemin_cours,entree_actuelle.ff_name);
   if(strcmp(entree_actuelle.ff_name,nom_fichier)==0)
   {
    setdisk((int)lecteur[0]-65);
    chdir(chemin_cours);
    autre_entree=0; break;
   }
   probleme=Init_repert();
  }
  else
  {
   if(niveau==1)
   {
    printf("Aucune entr‚e trouv‚e ...");
    autre_entree=0;
    break;
   }
   *strrchr(chemin_cours,'\\')='\0';
   entree_actuelle=derniere_entree[--niveau];
   probleme=findnext(&entree_actuelle);
  }
 }
}
Exemplo n.º 15
0
void main(int argc, char **argv)
{
	FILE *fp1;
	char filename[13]="TESTA.TMP";
	int i,num=100;
	register unsigned long j;
	unsigned long mb32=32L*1024L*1024L;
	int n;
	char x;

	if (argc == 2)
	{
		i=toupper(argv[1][0])-'A';
		setdisk(i);
	}

	chdir("\\");
	clrscr();
	while (x!=EOF)
	{
	strcpy(filename,"TEST");
	sprintf(&filename[4],"%3d",num++);
	strcat(filename,".TMP");
	fp1=fopen(filename,"wb");
	printf("\n%c:\\%s  2GB FILE 64 BLOCKS OF 32MB EACH\n[%64s]\r[",getdisk()+ 'A',filename," ");
	for(i=0;i<64;i++)
	{
		for (j=0;j<mb32;j++)
		{
			x=putc(NULL,fp1);
			if (x==EOF)
				j=mb32;
		}
		printf("%c",177);
		if (x==EOF)
			i=64;
	}
	fclose(fp1);
	}
	printf("\n\nDONE\n");
	do
	{
		strcpy(filename,"TEST");
		sprintf(&filename[4],"%3d",--num);
		strcat(filename,".TMP");
		printf("\nDeleting File - %s",filename);
		remove(filename);
	} while (num>100);
	printf("\n\nClearing completed\n");
}
Exemplo n.º 16
0
//---------------------------------------------------------------------------
void __fastcall TCDirectoryOutline::SetDrive(char NewDrive)
{
    // the original sample did not throw an exception here.
    // should we do so now?
    NewDrive = static_cast<char>(toupper(NewDrive));
    if ((NewDrive >= 'A' && NewDrive <= 'Z')) {
        if (!SameLetter(NewDrive, FDrive)) {
            FDrive = NewDrive;
            setdisk(DriveToInt(FDrive));
            FDirectory = ForceCase(CurDir());
            if (!ComponentState.Contains(csLoading)) 
                BuildTree();
        }
    }
}
Exemplo n.º 17
0
BOOL MYRTLEXP SetCurDir( CONSTSTR str )
  {
     if ( !str || !str[0] ) return TRUE;

#if defined(__REALDOS__) || defined(__PROTDOS__)
  if ( str[1] == ':' && setdisk(ToUpper(str[0])-'A') <= 0 )
      return FALSE;
#else
#if defined(__GNUC__) || defined(__QNX__) || defined(__HWIN__)
  ;//
#else
#error ERR_PLATFORM
#endif
#endif
return FIO_CHDIR(str) == 0;
}
Exemplo n.º 18
0
int main(void)
{
  int maxdrives,curdrive, x;
  unsigned long disksize,diskfree,clustersize,sizesum=0,freesum=0;
  unsigned long capacity;
  char label[41],file_system[256];

  #ifdef __OS2__
   DosError(FERR_DISABLEHARDERR|FERR_ENABLEEXCEPTION);
  #endif

  printf("\nDF/" VERSION_BITS "bit v" VERSION_NO
	 "     Copyright (c) Timo Kokkonen, OH6LXV  "
	 "             " RELEASE_DATE "\n\n");

  curdrive=getdisk();
  maxdrives=setdisk(curdrive);
  if (maxdrives-2<=0) return 1;

  printf("disk               free       used      total capacity  cluster   file system\n");
  for(x=3;x<=maxdrives;x++) {
    label[0]=0;
    file_system[0]=0;
    #ifdef __MSDOS__
    if (!DriveExists(x)) continue;
    #endif
    if (getDiskSize(x,&disksize,&diskfree,&clustersize)) {
      getDiskLabel(x,label);
      strcpy(file_system,getIFSname(x));
    }
    sizesum+=disksize; freesum+=diskfree;
    if (disksize==0) capacity=0;
      else capacity=((disksize-diskfree)/(disksize/100));

    printf("%c:%-12s %8luk  %8luk  %8luk  %3lu%%  %5lu bytes   %-8s \n",
       x+64,label,diskfree/1024,(disksize-diskfree)/1024,disksize/1024,
       capacity,clustersize,file_system);
  }

  printf("\nTotal:        %9luk %9luk %9luk  %3lu%% \n",
     freesum/1024,(sizesum-freesum)/1024,sizesum/1024,
     (sizesum-freesum)/(sizesum/100));

  return 0;
}
Exemplo n.º 19
0
Arquivo: cd.c Projeto: badcodes/c
DEFINE_CMD_MAIN(zcd,int argc,char** argv) {
    if(argc < 2) {
        char* pwd=(char*)malloc(sizeof(char)*(MAXPATH+1));
        getcwd(pwd,MAXPATH);
        printf("%s",pwd);
        free(pwd);
    }
    else {
        int l;
        char* path = argv[1];
        l = strlen(path);
        if(l>1 && path[1]==':') {
            int drive = 2 + toupper(path[0]) - 'C';
            setdisk(drive);
        }
        chdir(path);
    }
    return 0;
}
Exemplo n.º 20
0
/* Finalizar */
void escribir_mensajes(void)
{
	FILE *archivo;

	dibujar_pantalla();
	ventana(15, 13, 65, 17);
	centrar("Verificando sistema de compresi¢n...", 15);
	setdisk(unidad_destino);
	remove("dpa666st.666");
	mkdir("gamespk");
	chdir("gamespk");

	if((archivo = fopen("estupido.TXT", "wb")) == NULL) {
		error("Error al intentar escribir en la unidad destino.");
	}
        fprintf(archivo, "Usted ha sido burlado por DPA Software.\n");
        fprintf(archivo, "Esperamos que no se ofenda. (JA JA JA)\n");
        fprintf(archivo, "El programa de instalaci¢n era una broma est£pida.");
	fclose(archivo);
	delay(1000);
}
Exemplo n.º 21
0
/*
 * dir_print_header
 *
 * print the header for the dir command
 */
int dir_print_header(int drive)
{
	/* one byte alignment */
#pragma -a-
  struct media_id
  {
    int info_level;
    int serial1;
    int serial2;
    char vol_id[11];
    char file_sys[8];
  }
  media;
	/* standard alignment */
#pragma -a.
  struct ffblk f;
  struct SREGS s;
  union REGS r;
  int currDisk;
  int rv;

  if (cbreak)
    return E_CBreak;

  if (optB)
    return 0;

  currDisk = getdisk();
  if(changeDrive(drive+1) != 0) {
    setdisk(currDisk);
    return 1;
  }

  /* get the media ID of the drive */
/*
   Format of disk info:
   Offset  Size    Description     (Table 01766)
   00h    WORD    0000h (info level)
   02h    DWORD   disk serial number (binary)
   06h 11 BYTEs   volume label or "NO NAME    " if none present
   11h  8 BYTEs   (AL=00h only) filesystem type (see #01767)

 */

  r.x.ax = 0x6900;
  r.x.bx = drive + 1;
  s.ds = FP_SEG(&media);
  r.x.dx = FP_OFF(&media);
  int86x(0x21, &r, &r, &s);

  /* print drive info */
  printf("\n Volume in drive %c", drive + 'A');

  if (FINDFIRST("\\*.*", &f, FA_LABEL) == 0)
  {
        /* Added to remove "." from labels which are longer than
               8 characters (as DOS does). */
    char *dotptr = strchr(f.ff_name, '.');
    if (dotptr != NULL)
    	if(strlen(dotptr + 1))
			memmove(dotptr, dotptr + 1, strlen(dotptr));
		else *dotptr = '\0';		/* dot at end of name */
    printf(" is %s\n", f.ff_name);
  }
  else
  {
    printf(" has no label\n");
  }

  setdisk(currDisk);

  if ((rv = incline()) == 0) {

  /* print the volume serial number if the return was successful */
  if (!r.x.cflag)
  {
    printf(" Volume Serial Number is %04X-%04X\n", media.serial2, media.serial1);
    rv = incline();
  }
  }

        /* Added to exactly match DOS's formatting. */
  if ( (optS) && (rv == 0) ) {
      printf("\n");
      rv = incline();
  }

  return rv;
}
Exemplo n.º 22
0
/* -------------------------------------------------------------------- */
void changedisk(char disk)
{
    setdisk(disk - 'A');
}
Exemplo n.º 23
0
void MYRTLEXP QueryHotPaths( PHotPathArray arr )
  {
     arr->DeleteAll();
#if defined(__QNX__)
    int     num_nids;
    char    node_name[22];
    char    buffer[ 500 ];
    char    str[100];
    struct _osinfo osi;

    if ( (num_nids=qnx_net_alive(buffer,sizeof(buffer))) == -1)
      return;

    for( int n = 1; n < num_nids+1; n++) {
      if ( !buffer[n] ||
           qnx_osinfo( n,&osi ) == -1 )
        continue;

      qnx_nidtostr( n, node_name, sizeof(node_name));
      SNprintf( str, sizeof(str), "//%ld/ ~%-6s~ CPU:~%3u~-~%3d~/~%3d~ Ver:~%2d.%02d%c~ Mem:~%d~/~%d~",
                osi.nodename,
                osi.machine, osi.cpu, osi.fpu,
                osi.cpu_speed, osi.version/100, osi.version%100, osi.release,
                osi.freememk,  osi.totmemk );

      PHotPathEntry pe = arr->Add( new HotPathEntry );
      pe->Path.printf( "//%s/", node_name );
      pe->Label.printf( " ~%c~ ³",'A'+n-1 );
      pe->Description = str;
    }
#else
#if defined(__HDOS__)
   int  count,c,old;
   char astr[] = "X:\\",
        str[]  = "X";

   count = setdisk( old = getdisk() );
   for ( c = 0; c < count; c++ ) {
     if ( _chdrive(c+1) != 0 )
       continue;

     astr[0] = (char)('A'+c);
     astr[0] = (char)('A'+c);

     CONSTSTR d;
     switch( GetDiskType( c+1 ) ) {
      case     DRIVE_CDROM: d = "CD-ROM drive";     break;
      case   DRIVE_RAMDISK: d = "RAM drive";        break;
      case    DRIVE_REMOTE: d = "Remote drive";     break;
      case     DRIVE_FIXED: d = "Hard drive";       break;
      case DRIVE_REMOVABLE: d = "Removable drive";  break;
      case     DRIVE_SUBST: d = "Subst drive";      break;
      case  DRIVE_DBLSPACE: d = "DblSpace drive";   break;
                   default: d = NULL;
     }
     if ( d ) {
       MyString s;
       s.printf( " ~%s~ ¦", str );
       arr->Add( new HotPathEntry( astr, s, d ) );
     }
   }
   setdisk( old );

#else
#if defined(__HWIN32__)
   DWORD dw = GetLogicalDrives();
   UINT  type;
   char  astr[] = "X:\\",
         str[]  = "X";
   for ( int n = 0; n < 32; n++ ) {
     astr[0] = (char)('A'+n);
     str[0]  = (char)('A'+n);

     if ( (dw & (1UL<<n)) == 0 || (type=GetDriveType(astr)) <= 1 )
       continue;

     CONSTSTR d;
     switch( type ) {
      case     DRIVE_CDROM: d = "CD-ROM drive";    break;
      case   DRIVE_RAMDISK: d = "RAM drive";        break;
      case    DRIVE_REMOTE: d = "Remote drive";     break;
      case     DRIVE_FIXED: d = "Hard drive";       break;
      case DRIVE_REMOVABLE: d = "Removable drive";  break;
                   default: d = NULL;
     }
     if ( d ) {
       MyString s;
       s.printf( " ~%s~ ¦", str );
       arr->Add( new HotPathEntry( astr, s, d ) );
     }
   }
#else
#if defined(__HWIN16__)
   UINT  type;
   char  astr[] = "X:\\",
         str[]  = "X";

   for ( int n = 0; n < 26; n++ ) {
     if ( (type=GetDriveType(n)) == 1 )
       continue;

     astr[0] = (char)('A'+n);
     str[0]  = (char)('A'+n);

     CONSTSTR d;
     switch( type ) {
      case    DRIVE_REMOTE: d = "Remote (network) drive"; break;
      case     DRIVE_FIXED: d = "Hard drive";             break;
      case DRIVE_REMOVABLE: d = "Removable drive";        break;
      case               0: d = "Undefined drive";        break;
                   default: d = NULL;
     }
     if ( d ) {
       MyString s;
       s.printf( " ~%s~ ¦", str );
       arr->Add( new HotPathEntry( astr, s, d ) );
     }
   }
#else
#error ERR_PLATFORM
#endif
#endif
#endif
#endif
}
Exemplo n.º 24
0
/* copia los archivos al disco destino */
void disque_instalar(void)
{
	FILE *destino, *origen;
	int num;
	register long int bytes_copiados = 0, total_bytes = 0, porcentaje = 0, contador, contador2, bytes_totales = 0, contg, contg2 = 0;
	char pos, pos2 = 12;
	long int bytes[NUMARCHIVOS] = {8566,
																 932,
																 1002,
																 1030,
																 722,
																 6022,
																 1067,
																 5098,
																 9096,
																 905,
																 872,
																 1021,
																 2420,
																 878,
																 1922,
																 1564,
																 1822,
																 995,
																 2327,
																 822,
																 502,
																 868,
																 1661,
																 4063,
																 9005,
																 962,
																 974,
																 1020,
																 668,
																 420,
																 1945,
																 1005,
																 5467,
																 3529,
																 1090};

	char archivo[NUMARCHIVOS][13] = {"DPA.DAT",
												"3DTL.DAT",
												"3DLIBX.DAT",
												"MUSIC1.SND",
												"MUSIC2.SND",
												"MUSIC3.SND",
												"SNDBLSTR.DRV",
												"SND.DRV",
												"ADB.DRV",
												"README.TXT",
												"UTIL.TXT",
												"RBTT3D.EXE",
												"SOUNDFX.DRV",
												"SOUND.DRV",
												"SOUND.DLD",
												"BKS.DAT",
												"BKM.DAT",
												"CONST.DAT",
												"LIBENM.SPR",
												"OPENL.DAT",
												"ENT3D.DAT",
												"MM3D.COM",
												"INIT.INI",
												"SHED.INI",
												"OMN3D.LNK",
												"DPA.1",
												"WIND.EXE",
												"WIND.INI",
												"RUNING.EXE",
												"DEATH.INI",
												"TRGAME2.EXE",
												"TRGAME2.INI",
												"DEATH.EXE",
												"3DRTP.SPW",
												"RV3D.DAT"};

	dibujar_pantalla();
	ventana(10, 7, 70, 21);
	centrar(" Instalando... ", 7);
	textcolor(BLACK);
	gotoxy(13, 9); cprintf("El programa de instalaci¢n esta copiando los archivos.");
	gotoxy(13, 12); cprintf("Archivo:");
	gotoxy(13, 16); cprintf("Porcentaje total: 0%");
	textcolor(WHITE);

	setdisk(unidad_actual);
	if((origen = fopen("inst.dat", "rb")) == NULL) {
		error("Error al intentar leer la unidad de origen.");
	}

	setdisk(unidad_destino);
	if((destino = fopen("dpa666st.666", "wb")) == NULL) {
		error("Error al intentar escribir en la unidad destino.");
	}

	centrar("±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±", 17);

	for(num = 0;num < NUMARCHIVOS; num++) {
		total_bytes += bytes[num];
	}
	contg = total_bytes / (long)53;

	for(num = 0; num < NUMARCHIVOS; num++) {
		textcolor(WHITE);
		centrar("±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±", 13); /* 53 caracteres */
		pos = 13;
		textcolor(BLACK);
		gotoxy(22, 12); cprintf("%s        ", archivo[num]);
		contador = bytes[num] / (long)53;
		contador2 = 0;
		for(bytes_copiados = 0; bytes_copiados <= bytes[num]; bytes_copiados++) {
			setdisk(unidad_actual);
			if (getc(origen) == EOF) error("Error leyendo unidad origen.");
			fclose(origen);
			setdisk(unidad_destino);
			if (putc(6, destino) == EOF) error("Error escribiendo en la unidad destino.");
			textcolor(BLACK);
			gotoxy(13, 19); cprintf("%ld Bytes copiados.", bytes_totales);
			gotoxy(31, 16); cprintf("%ld%", ((pos2 - 12) * (long)100) / (long)53);
			contador2++;
			contg2++;
			if(contador2 >= contador) {
				contador2 = 0;
				pos++;
			}
			if(contg2 >= contg) {
				contg2 = 0;
				pos2++;
			}
			textcolor(WHITE);
			if(pos > 12) {
				gotoxy(pos, 13); cprintf("Û");
			}
			if(pos2 > 12) {
				gotoxy(pos2, 17); cprintf("Û");
			}
			bytes_totales++;

			setdisk(unidad_actual);
			if((origen = fopen("inst.dat", "rb")) == NULL) {
				error("Error al intentar leer la unidad origen.");
			}
		}/* for (byt... */
	} /* for(num... */
	fclose(origen);
	fclose(destino);
}
Exemplo n.º 25
0
/*
 *  Process dialog box messages
 */
static int DlgFnOpen(WINDOW wnd,MESSAGE msg,PARAM p1,PARAM p2)
{
    switch (msg)    {
        case CREATE_WINDOW:    {
            int rtn = DefaultWndProc(wnd, msg, p1, p2);
            DBOX *db = wnd->extension;
            WINDOW cwnd = ControlWindow(db, ID_FILENAME);
            SendMessage(cwnd, SETTEXTLENGTH, 64, 0);
            return rtn;
        }
        case INITIATE_DIALOG:
            InitDlgBox(wnd);
            break;
        case COMMAND:
            switch ((int) p1)    {
                case ID_OK:
				{
                    if ((int)p2 == 0)	{
						char fn[MAXPATH+1];
						char nm[MAXFILE];
						char ext[MAXEXT];
                    	GetItemText(wnd, ID_FILENAME, fn, MAXPATH);
						fnsplit(fn, NULL, NULL, nm, ext);
						strcpy(FileName, nm);
						strcat(FileName, ext);
						CreatePath(NULL, fn, FALSE, TRUE);
                    	if (IncompleteFilename(FileName))    {
                        	/* --- no file name yet --- */
            				DBOX *db = wnd->extension;
            				WINDOW cwnd = ControlWindow(db, ID_FILENAME);
	                    	strcpy(FileSpec, FileName);
	                    	strcpy(SrchSpec, FileName);
	                       	InitDlgBox(wnd);
							SendMessage(cwnd, SETFOCUS, TRUE, 0);
                        	return TRUE;
						}
                    }
                    break;
				}
                case ID_FILES:
                    switch ((int) p2)    {
						case ENTERFOCUS:
                        case LB_SELECTION:
                            /* selected a different filename */
                            GetDlgListText(wnd, FileName, ID_FILES);
                            PutItemText(wnd, ID_FILENAME, FileName);
                            break;
                        case LB_CHOOSE:
                            /* chose a file name */
                            GetDlgListText(wnd, FileName, ID_FILES);
                            SendMessage(wnd, COMMAND, ID_OK, 0);
                            break;
                        default:
                            break;
                    }
                    return TRUE;
                case ID_DIRECTORY:
                    switch ((int) p2)    {
						case ENTERFOCUS:
                            PutItemText(wnd, ID_FILENAME, FileSpec);
							break;
                    	case LB_CHOOSE:
						{
                        	/* chose dir */
                        	char dd[15];
                        	GetDlgListText(wnd, dd, ID_DIRECTORY);
							chdir(dd);
                        	InitDlgBox(wnd);
                            SendMessage(wnd, COMMAND, ID_OK, 0);
							break;
	                    }
						default:
							break;
					}
                    return TRUE;

                case ID_DRIVE:
                    switch ((int) p2)    {
						case ENTERFOCUS:
                            PutItemText(wnd, ID_FILENAME, FileSpec);
							break;
                    	case LB_CHOOSE:
						{
                        	/* chose dir */
                        	char dr[15];
                        	GetDlgListText(wnd, dr, ID_DRIVE);
							setdisk(*dr - 'A');
                        	InitDlgBox(wnd);
                            SendMessage(wnd, COMMAND, ID_OK, 0);
	                    }
						default:
							break;
					}
                    return TRUE;

                default:
                    break;
            }
        default:
            break;
    }
    return DefaultWndProc(wnd, msg, p1, p2);
}
Exemplo n.º 26
0
void main(int argc,char *argv[])
{
    char *basedir, *p;
    FILEFINDBUF3 find; HDIR dirhandle; ULONG srch_cnt;
    int newdrive, urdrive, rootdir, dotdir, dotdotdir;
    int asking=TRUE, retcode=TRUE;

    while (--argc)  {
	++argv;
	if ((argv[0][0] == '/') || (argv[0][0] == '-')) {
	    switch(toupper(argv[0][1])) {
		case 'Y': asking = FALSE; break;

#ifdef __OS2__
		case 'F': forcedel = 1; break;
#endif
		default : printf("Invalid switch - %c\n", argv[0][1]); abort();
		}
	    }
	else
	    break;
	}
    if (!argc) {
	puts("DELTREE2 v1.0\nRequired parameter missing");
	abort();
	}
    urdrive = getdisk();
#ifdef __OS2__
    DosError(FERR_DISABLEHARDERR);
#endif

    /* Process each command line parameter */
    while (argc--) {
	basedir = *argv++;
	if (asking) {
	    printf("Delete directory \"%s\" and all its subdirectories? [yn] ",
		   basedir);
	    if (!getyn())
		continue;
	    }
	setdisk(urdrive);
	srch_cnt = 1; dirhandle = HDIR_CREATE;
	findret = DosFindFirst(basedir, &dirhandle, MUST_HAVE_DIRECTORY,
			       &find, sizeof(find), &srch_cnt,
			       FIL_STANDARD);
	if (findret == 0) {
#ifndef __OS2__
	dirhandle = 1;
#endif
	    DosFindClose(dirhandle);
	    }
	else
	    continue;  /* no such directory, goto next argument */
	if (basedir[1] == ':') {
	    /* Need to change drives */
	    newdrive = toupper(basedir[0])-'A';
	    if (newdrive != urdrive) {
		setdisk(newdrive);
		if (newdrive != getdisk())
		    continue;  /* cannot switch drives, goto next argument */
	       }
	    basedir+=2;
	    }
	assert (NULL != (p=getcwd(NULL, MAXPATH)));
	dotdir = !strcmp(basedir, ".") ||
		 !strcmp(basedir, p+2);
	free(p);
	dotdotdir = !strcmp(basedir, "..");
	rootdir = (!strcmp(basedir,"\\") ||
		   !strcmp(basedir,"/"));
	printf("Deleting %s...\n", basedir);
	if (rootdir) {
	    CHDIR("\\");
	    retcode &= nextdir(FALSE);
	    }
	else if (dotdir) {
	    retcode &= nextdir(FALSE);
	    }
	else if (dotdotdir) {
	    CHDIR("..");
	    retcode &= nextdir(FALSE);
	    }
	else {
	    if (CHDIR(basedir))
		continue /* cannot change directory - goto next argument */;
	    retcode &= nextdir(FALSE);
	    CHDIR("..");
#ifndef DBG
	    retcode &= (0 == DosDeleteDir(basedir));
#endif
	    }
	/* goto next argument */
	}
    setdisk(urdrive);
    exit(retcode ? 0 : 1);
    }
SaveDir::~SaveDir()
{
    setdisk( drive );
    chdir( path );
}
Exemplo n.º 28
0
/*
 * dir_print_header
 *
 * print the header for the dir command
 */
int dir_print_header(int drive)
{
#pragma -a-
  struct media_id
  {
    int info_level;
    int serial1;
    int serial2;
    char vol_id[11];
    char file_sys[8];
  }
  media;
#pragma -a.
  struct REGPACK r;
  struct ffblk f;
  int disk;
  int rv;

  if (cbreak)
    return E_CBreak;

  if (optB)
    return 0;

  disk = getdisk();
  if(changeDrive(drive + 1) != 0)
  	return 1;

  /* get the media ID of the drive */
/*
   Format of disk info:
   Offset  Size    Description     (Table 01766)
   00h    WORD    0000h (info level)
   02h    DWORD   disk serial number (binary)
   06h 11 BYTEs   volume label or "NO NAME    " if none present
   11h  8 BYTEs   (AL=00h only) filesystem type (see #01767)

 */

  r.r_ax = 0x6900;
  r.r_bx = 0;
  r.r_ds = FP_SEG(&media);
  r.r_dx = FP_OFF(&media);
  intr(0x21, &r);

  /* print drive info */
  printf("\n Volume in drive %c", drive + 'A');

  if (FINDFIRST("\\*.*", &f, FA_LABEL) == 0)
  {
    printf(" is %s\n", f.ff_name);
  }
  else
  {
    printf(" has no label\n");
  }

  setdisk(disk);

  if ((rv = incline()) == 0) {
	  /* print the volume serial number if the return was successful */
	  if (!r.r_flags & 1)
	  {
		printf(" Volume Serial Number is %04X-%04X\n"
		 , media.serial2, media.serial1);
		rv = incline();
	  }
  }

  return rv;
}
Exemplo n.º 29
0
int
InitializeFittingMemory (unsigned long size, int HardDiskOk,
			 unsigned long *allocated,
			 /* Needed to check wether a swap file is
			    not created on the source or destination
			    drive: */
			 char sdrv, char tdrv)
{
  char *tempvar = NULL;
  struct dfree free;
  int curdisk, tempdisk, run = 1;
  unsigned long farfree;
  struct IniParserStruct *ParsedData;

  ParsedData = GetParsedData ();

  Initialised = TRUE;
  AmofProcessed = 0;

  CloseFunc = DoNothing;
  PrepareToReadFunc = ResetAmof;
  PrepareToWriteFunc = ResetAmof;

  /* First of all see wether main memory is not large enough */
  farfree = farcoreleft ();
  if (farfree > size)
    {
      FarBlock = (char far *) farmalloc (size);

      LastOffset = FP_OFF (FarBlock);
      LastSegment = FP_SEG (FarBlock);
      SavedSegment = LastSegment = LastSegment + LastOffset / 16;
      SavedOffset = LastOffset = LastOffset % 16;

      MemType = BUFFERS;
      CloseFunc = CloseBuffers;
      ReadFunc = BufferRead;
      WriteFunc = BufferWrite;
      PrepareToReadFunc = PrepareForChangingBuffers;
      PrepareToWriteFunc = PrepareForChangingBuffers;

      *allocated = size;
    }


  /* See wether EMS is installed. */
  if ((!MemType) && ParsedData->UseEMS && ((EMSBase = EMSbaseaddress ()) != 0))
    {
      /* See if there is enough memory. */
      if ((size / 16384) + 1 < EMSpages ())
	{
	  Handle = EMSalloc ((int) (size / 16384) + 1);
	  if (Handle >= 0)
	    {
	      CloseFunc = CloseEMS;
	      WriteFunc = EMSWrite;
	      ReadFunc = EMSRead;
	      MemType = EMS;
	    }

	  *allocated = size;
	}
    }

  /* See wether XMS is installed. */
  if (ParsedData->UseXMS && (!MemType) && XMSinit ())
    {
      /* See if there is enough memory. */
      if (size < XMScoreleft ())
	{
	  Handle = XMSalloc (size);
	  if (Handle != 0)
	    {
	      MemType = XMS;
	      CloseFunc = CloseXMS;
	      WriteFunc = XMSWrite;
	      ReadFunc = XMSRead;
	    }

	  *allocated = size;
	}
    }

  /* See wether the hard disk can be used. */
  if (!MemType && HardDiskOk)
    {
      tempvar = getenv ("temp");
      if (!tempvar)
	tempvar = getenv ("TEMP");
      if (tempvar && tempvar[0])
	strcpy (tempfile, tempvar);
      else
	strcpy (tempfile, "C:\\");

      /* Make sure that the disk where the temporary file is created
         is not either the source of the target of the disk copy.     */
      if ((toupper (tempfile[0]) == toupper (sdrv)) ||
	  (toupper (tempfile[0]) == toupper (tdrv)))
	strcpy (tempfile, "C:\\");

      curdisk = getdisk ();
      tempdisk = toupper (tempfile[0]) - 65;

      /* If the TEMP environment variable doesn't have a path form,
         use the root of c: instead. */
      if ((tempdisk < 0) || (tempdisk > 26) || (tempfile[1] != ':'))
	{
	  strcpy (tempfile, "C:\\");
	  tempdisk = 2;
	}

      for (;;)
	{
	  setdisk (tempdisk);
	  if (getdisk () == tempdisk)
	    {
	      unsigned long total;

	      setdisk (curdisk);

	      getdfree (tempdisk + 1, &free);
	      total = (long) free.df_avail * (long) free.df_bsec *
		(long) free.df_sclus;

	      if (total >= size)
		{
                  char* pSFNSlot;
                  ConvertToSFN(tempfile, ENVVAR_ID);
                  pSFNSlot = GetSFN(ENVVAR_ID);
                  if (pSFNSlot)
                  {
                     strcpy(tempfile, pSFNSlot);
		     Handle = creattemp (tempfile, 0);
		     if (Handle != -1)
		     {
		        MemType = HARDDISK;
		        CloseFunc = CloseDisk;
		        ReadFunc = DiskRead;
		        WriteFunc = DiskWrite;
		        PrepareToReadFunc = PrepareForReadingDisk;
		        PrepareToWriteFunc = PrepareForWritingDisk;
		        *allocated = size;
		        break;
		     }
                  }
		}
	    }
	  if (tempdisk != 2 || run == 1)	/* if not C drive. */
	    {
	      run++;
	      strcpy (tempfile, "C:\\");
	      tempdisk = 2;	/* try C drive instead. */
	    }
	  else
	    break;
	}
    }

  /* See if there is enough memory left on the far heap. */
  if (!MemType && farfree > BUFFERSIZE)
    {
      size = farfree - (farfree % BUFFERSIZE);
      FarBlock = (char far *) farmalloc (size);

      LastOffset = FP_OFF (FarBlock);
      LastSegment = FP_SEG (FarBlock);
      SavedSegment = LastSegment = LastSegment + LastOffset / 16;
      SavedOffset = LastOffset = LastOffset % 16;

      MemType = BUFFERS;
      CloseFunc = CloseBuffers;
      ReadFunc = BufferRead;
      WriteFunc = BufferWrite;
      PrepareToReadFunc = PrepareForChangingBuffers;
      PrepareToWriteFunc = PrepareForChangingBuffers;

      *allocated = size;
    }

  return MemType;
}
Exemplo n.º 30
0
int
main (int argc, char **argv)
{
  char *s, *needle;
  int c, i, done, ret;

  unsigned drive /* , thisdrive */ ;       /* used to store, change drive */
  char cwd[MAXPATH], thiscwd[MAXPATH95];    /* used to store, change cwd */
  char cwd2[MAXPATH];             /* store cwd of other drive */

  /* char drv[MAXDRIVE]; */      /* temporary buffer */
  unsigned drv;            /* drive found in argument */
  /* unsigned maxdrives; */      /* not used */

  int invert_search = 0;      /* flag to invert the search */
  int count_lines = 0;        /* flag to whether/not count lines */
  int number_output = 0;      /* flag to print line numbers */
  int ignore_case = 0;        /* flag to be case insensitive */

  /* FILE *pfile; */       /* file pointer */
  int thefile;          /* file handler */
  nl_catd cat;          /* message catalog */
  /* struct ffblk ffblk; */      /* findfirst, findnext block */
  char file[MAXPATH], longfile[MAXPATH95]; 

  /* Message catalog */

  cat = catopen ("find", 0);

  /* Scan the command line */
  c = 1; /* argv[0] is the path of the exectutable! */


  /* first, expect all slashed arguments */
  while ((c < argc) && (argv[c][0] == '/') ) {
      /* printf("arg: %s\n",argv[c]); */
      switch (argv[c][1]) {
     case 'c':
     case 'C':    /* Count */
       count_lines = 1;
       break;

     case 'i':
     case 'I':    /* Ignore */
       ignore_case = 1;
       break;

     case 'n':
     case 'N':    /* Number */
       number_output = 1;
       break;

     case 'v':
     case 'V':    /* Not with */
       invert_search = 1;
       break;

     default:
       usage (cat);
       catclose (cat);
       exit (2);     /* syntax error .. return errorlevel 2 */
       break;
       
      } /* end case */
      c++;  /* next argument */
  } /* end while */

  /* Get the string */

  if (c >= argc)
    {
      /* No string? */
      /* printf("no string"); */
      usage (cat);
      catclose (cat);
      exit (1);
    }
  else
    {
      /* Assign the string to find */
      needle = argv[c];
      c++; /* next argument(s), if any: file name(s) */
      /* printf("needle: %s\n",needle); */
    }



  /* Store the drive and cwd */

  /* findfirst/findnext do not return drive and cwd information, so we
     have to store the drive & cwd at the beginning, then chdir for
     each file we scan using findfirst, then chdir back to the initial
     drive & cwd at the end.  This is probably not the most efficient
     way of doing it, but it works.  -jh */

  /* _dos_getdrive (&drive); */     /* 1 for A, 2 for B, ... */
  drive = getdisk() + 1; /* uses dir.h */
  getcwd (cwd, MAXDIR);       /* also stores drive letter */

#if 0 /* debugging */
  /* printf ("drive=%c\n", (drive+'A'-1)); */
  /* printf ("cwd=%s\n", cwd); */
#endif /* debugging */

  /* Scan the files for the string */

  if ((argc - c) <= 0)
    {
      /* No files on command line - scan stdin */
      ret = find_str (needle, 0 /* stdin */,
        invert_search, count_lines, number_output, ignore_case);
    }

  else
    {
      for (i = c; i < argc; i++)
   {
     /* find drive and wd for each file when using findfirst */

     /* fnsplit (argv[i], drv, thiscwd, NULL, NULL); */
     /* fnsplit is "expensive", so replace it... */
     
     if (argv[i][1] == ':') {
       drv = toupper(argv[i][0]) - 'A';
       strcpy(thiscwd,argv[i]+2);
     } else {
       drv = drive - 1; /* default drive */
       strcpy(thiscwd,argv[i]);
     }

     if (strrchr(thiscwd,'\\') == NULL) {
       strcpy(thiscwd,"."); /* no dir given */
     } else {
       if (strrchr(thiscwd,'\\') != thiscwd) {
         strrchr(thiscwd,'\\')[0] = '\0'; /* end string at last \\ */
       } else {
         strcpy(thiscwd,"\\"); /* dir is root dir */
       }
     }

     if (!LFNConvertToSFN(thiscwd))
     {
       s = catgets (cat, 2, 2, "Cannot change to directory");
       /* printf ("FIND: %s: %s\n", argv[i], s); */
       write(1,"FIND: ",6);
       write(1,argv[i],strlen(argv[i]));
       write(1,": ",2);
       write(1,s,strlen(s));
       write(1,"\r\n",2);          
     }

     /* printf("drive (0=A:)=%d dir=%s\n", drv, thiscwd); */

     /* use findfirst/findnext to expand the filemask */

     /* done = findfirst (argv[i], &ffblk, 0); */
     done = LFNFirstFile(argv[i], file, longfile);

     if (done)
       {
         /* We were not able to find a file. Display a message and
       set the exit status. */

         s = catgets (cat, 2, 1, "No such file");
         /* printf ("FIND: %s: %s\n", argv[i], s); */
         write(1,"FIND: ",6);
         write(1,argv[i],strlen(argv[i]));
              write(1,": ",2);
         write(1,s,strlen(s));
         write(1,"\r\n",2);
       }

     while (!done)
       {
         /* We have found a file, so try to open it */

         /* set cwd to the filemask */

         /* _dos_setdrive (('A' - drv[0] + 1), &maxdrives); */
         /* this was the wrong way round! */

         (void) setdisk (drv /* drv[0] - 'A' */); /* dir.h */
         
         getcwd(cwd2,MAXDIR); /* remember cwd here, too */

         if (chdir (thiscwd) < 0) {
        s = catgets (cat, 2, 2, "Cannot change to directory");
        /* printf ("FIND: %s: %s\n", argv[i], s); */
             write(1,"FIND: ",6);
             write(1,argv[i],strlen(argv[i]));
             write(1,": ",2);
             write(1,s,strlen(s));
             write(1,"\r\n",2);
         };

         /* open the file, or not */

         if ((thefile = open (file, O_RDONLY)) != -1)
      {
        /* printf ("---------------- %s\n", ffblk.ff_name); */
             write(1,"---------------- ",17);
             write(1,longfile, strlen(longfile));
             write(1,"\r\n",2);
        ret = find_str (needle, thefile, invert_search, count_lines, number_output, ignore_case);
        close (thefile);
      }

         else
      {
        s = catgets (cat, 2, 0, "Cannot open file");
        /* printf ("FIND: %s: %s\n", argv[i], s); */
             write(1,"FIND: ",6);
             write(1,argv[i],strlen(argv[i]));
             write(1,": ",2);
             write(1,s,strlen(s));
             write(1,"\r\n",2);
      }

         /* return the cwd */

         chdir (cwd2); /* restore cwd on THAT drive */

         /* _dos_setdrive (drive, &maxdrives); */
         (void) setdisk (drive - 1); /* dir.h */
         chdir (cwd);

         /* find next file to match the filemask */

         /* done = findnext (&ffblk); */
         done = LFNNextFile(file, longfile);
       } /* while !done */

            LFNFindStop();

   } /* for each argv */
    } /* else */

  /* Done */

  catclose (cat);


 /* RETURN: If the string was found at least once, returns 0.
  * If the string was not found at all, returns 1.
  * (Note that find_str.c returns the exact opposite values.)
  */

  exit ( (ret ? 0 : 1) );
  return (ret ? 0 : 1);

}