Beispiel #1
0
/* /DELETE command line option */
void Command_Line_Delete()
{
  Partition_Table *pDrive = &part_table[flags.drive_number-0x80];

  /* Delete the primary partition */
  if(0==strcmp(arg[1].choice,"PRI"))
    {
    if (arg[1].value != 0)			/* specified what to delete */
      {
      if (arg[1].value < 1 || arg[1].value >4)
	{
	printf("primary partition # (%ld) must be 1..4\n",(long)arg[1].value); exit(9);}

	Delete_Primary_Partition((int)(arg[1].value - 1));
		}
	else
	  {							/* no number given, delete 'the' partition */
	  int index,found,count;

	  for (count = 0, index = 0; index < 4; index++)
	    {
	    if(IsRecognizedFatPartition(pDrive->pri_part[index].num_type))
	      {
	      count++;
	      found = index;
	      }
	    }
	    if (count == 0)
	     printf("no partition to delete found\n");	/* but continue */
	    else
	      if (count > 1)
		{
		printf("%d primary partitions found, you must specify number to delete\n",count); exit(9);
		}
	      else
		{
		Delete_Primary_Partition(found);
		}
	    }
	} /* end PRI */

  /* Delete the extended partition */
  if(0==strcmp(arg[1].choice,"EXT"))
    {
    int index=3;

    do
      {
      if( ( (flags.version==FOUR)
       || (flags.version==FIVE)
       || (flags.version==SIX) )
       && (pDrive->pri_part[index].num_type==5) )
	{
	Delete_Primary_Partition(index);
	break;
	}
      if( ( (flags.version==W95)
       || (flags.version==W95B)
       || (flags.version==W98) )
       && ( (pDrive->pri_part[index].num_type==5)
       || (pDrive->pri_part[index].num_type==15) ) )
        {
        Delete_Primary_Partition(index);
        break;
        }

      index--;
      }while(index>=0);

    if(index<0)
      {
      printf("\nExtended DOS Partition not found...no partition deleted.\n");
      exit(9);
      }
    }

  /* Delete a Logical DOS Drive */
  if(0==strcmp(arg[1].choice,"LOG"))
    {
    if( (arg[1].value>=1) && (arg[1].value<=23) )
      {
      Delete_Logical_Drive( (int)(arg[1].value-1) );
      }
    else 
      {
      printf("\nLogical drive number  (%d) is out of range...Operation Terminated\n",arg[1].value);
      exit(9);
      }
    }

  /* Delete the partition by the number of the partition */
  if(0==strcmp(arg[1].choice,"NUM"))
    {
    if( (arg[1].value>=1) && (arg[1].value<=4) )
      {
      Delete_Primary_Partition( (int)(arg[1].value-1) );
      }
    else if( (arg[1].value>=5) && (arg[1].value<=28) )
      {
      Delete_Logical_Drive( (int)(arg[1].value-5) );
      }
    else  
      {
      printf("\nPartition number is out of range...Operation Terminated\n");
      exit(9);
      }
    }

  Shift_Command_Line_Options(2);
}
Beispiel #2
0
/* Delete Logical Drive Interface */
int Delete_Logical_Drive_Interface()
{
  char char_number[2];

  int drive_to_delete=0;
  int index=0;
  int input=0;
  int input_ok;
  Partition_Table *pDrive = &part_table[flags.drive_number-0x80];

  Clear_Screen(0);

  Print_Centered(1,"Delete Logical DOS Drive(s) in the Extended DOS Partition",BOLD);

  Display_Extended_Partition_Information_SS();

  BlinkPrintAt(4,19,"WARNING!");
  printf(" Data in a deleted Logical DOS Drive will be lost.");

  printAt (4,20,"What drive do you want to delete...............................? ");

  Determine_Drive_Letters();

  //char drive_lettering_buffer[8] [27];   this line is for reference
  /* Place code to find the min and max drive letter here. */

  input_ok=FALSE;

  do
    {
    flags.esc=FALSE;

    if( (flags.del_non_dos_log_drives==TRUE)
     && (pDrive->num_of_non_dos_log_drives>0) )
     {
     if(pDrive->num_of_non_dos_log_drives>9)
      pDrive->num_of_non_dos_log_drives=9;
     itoa(pDrive->num_of_non_dos_log_drives,char_number,10);
     input=(int)Input(1,69,20,CHAR,67,90,ESCR,0,0,"1",char_number);
     }
    else input=(int)Input(1,69,20,CHAR,67,90,ESCR,0,0,NULL,NULL);
    /* Note:  min_range and max_range will need adjusted!!!!! */
    /* Changes will have to be made because the first logical drive letter */
    /* on the selected drive may not be D:, the drive letters on the       */
    /* drive may not be sequential.                                        */

    if(flags.esc==TRUE) return(1);

    if(flags.esc==FALSE)
      {
      /* Ensure that the entered character is legitimate. */
      index=4;
      do
        {
        if( (drive_lettering_buffer[(flags.drive_number-128)] [index]>0)
         && (drive_lettering_buffer[(flags.drive_number-128)] [index]==input) )
          {
          input=index-4;
          input_ok=TRUE;
          index=30; /* break out of the loop */
          }

        index++;
        }while(index<=26);
      }

    }while(input_ok==FALSE);

  drive_to_delete=input;

  printAt(4,22,"Are you sure (Y/N)..............................? ");
  flags.esc=FALSE;
  input=(int)Input(1,54,22,YN,0,0,ESCR,0,0,NULL,NULL);

  if( (input==TRUE) && (flags.esc==FALSE) )
    {
    Delete_Logical_Drive(drive_to_delete);

    Clear_Screen(0);
    Print_Centered(1,"Delete Logical DOS Drive(s) in the Extended DOS Partition",BOLD);
    Display_Extended_Partition_Information_SS();
    input=(int)Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL);
    }

  return(0);
}