⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 userint2.c

📁 Fdisk 1.2.1 Freedos下硬盘分区软件
💻 C
📖 第 1 页 / 共 4 页
字号:
    }
}

/* 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);
}

/* Delete Non-DOS Partition User Interface */
void Delete_N_DOS_Partition_Interface()
{
  int input=0;

  Clear_Screen(0);
  Print_Centered(4,"Delete Non-DOS Partition",BOLD);

  Display_Primary_Partition_Information_SS();

  BlinkPrintAt(4,18,"WARNING!");

  printf(" Data in the deleted Non-DOS Partition will be lost.");
  printAt(4,19,"What Non-DOS Partition do you want to delete..? ");

  flags.esc=FALSE;
  input=(int)Input(1,52,19,NUM,1,4,ESCR,-1,0,NULL,NULL); /* 4 needs changed to the max num of partitions */

  if(flags.esc==FALSE)
    {
    Delete_Primary_Partition(input-1);

    Clear_Screen(0);
    Print_Centered(4,"Delete Non-DOS Partition",BOLD);
    Display_Primary_Partition_Information_SS();
    cprintAt(4,21,"Non-DOS Partition deleted");
    printAt(4,24,"                                    ");

    Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL);
    }
}

/* Delete Primary DOS Partition Interface */
void Delete_Primary_DOS_Partition_Interface()
{
  int input=0;
  int partition_to_delete;

  Clear_Screen(0);

  Print_Centered(4,"Delete Primary DOS Partition",BOLD);
  Display_Primary_Partition_Information_SS();

  BlinkPrintAt(4,19,"WARNING!");

  printf(" Data in the deleted Primary DOS Partition will be lost.");
  printAt(4,20,"What primary partition do you want to delete..? ");

  flags.esc=FALSE;
  input=(int)Input(1,52,20,NUM,1,4,ESCR,-1,0,NULL,NULL); /* 4 needs changed to the max num of partitions */

  if(flags.esc==FALSE)
    {
    partition_to_delete=input-1;

    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_Primary_Partition(partition_to_delete);

      Clear_Screen(0);

      Print_Centered(4,"Delete Primary DOS Partition",BOLD);
      /* */
      Display_Primary_Partition_Information_SS();
      cprintAt(4,21,"Primary DOS Partition deleted");

      Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL);
      }
    }
}

/* Display information for all hard drives */
void Display_All_Drives()
{
  int current_column_offset_of_general_drive_information;
  int current_column_offset=4;
  int current_line=3;
  int current_line_of_general_drive_information;
  int drive=1;
  int drive_letter_index=0;
  int index;

  long space_used_on_drive_in_MB;

  unsigned long usage;

  Determine_Drive_Letters();

  printAt(2,2,"Disk   Drv   Mbytes   Free   Usage");

  do
    {
    if(current_line>18)
      {
      current_line=3;
      current_column_offset=45;

      printAt(43,2,"Disk   Drv   Mbytes   Free   Usage");
      }

    /* Print physical drive information */
    current_column_offset_of_general_drive_information=current_column_offset;
    current_line_of_general_drive_information=current_line;
    space_used_on_drive_in_MB=0;

    /* Print drive number */
    Position_Cursor(current_column_offset_of_general_drive_information,current_line);
    cprintf("%d",drive);

    /* Print size of drive */
    Position_Cursor((current_column_offset_of_general_drive_information+10),current_line);
    Print_UL(part_table[drive-1].total_hard_disk_size_in_MB);

    /* Get space_used_on_drive_in_MB */
    index=0;
    do
      {
      if( (part_table[drive-1].pri_part[index].num_type!=5)
       && (part_table[drive-1].pri_part[index].num_type!=15)
       && (part_table[drive-1].pri_part[index].num_type!=0) )
       space_used_on_drive_in_MB
	+= part_table[drive-1].pri_part[index].size_in_MB;

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

    index=0;
    do
      {
      if(part_table[drive-1].log_drive[index].num_type>0)
       space_used_on_drive_in_MB
	+= part_table[drive-1].log_drive[index].size_in_MB;

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

    /* Print logical drives on disk, if applicable */

    drive_letter_index=0;
    do
      {
      if(drive_lettering_buffer[drive-1] [drive_letter_index]>0)
        {
        current_line++;

        if(current_line>18)
          {
          current_line=3;
          current_column_offset=45;

          printAt(43,2,"Disk   Drv   Mbytes   Free   Usage");
          }

        /* Print drive letter of logical drive */
        if( ( (drive_lettering_buffer[drive-1] [drive_letter_index]>='C')
         && (drive_lettering_buffer[drive-1] [drive_letter_index]<='Z') )
         || (flags.del_non_dos_log_drives==TRUE) )
          {
	  Position_Cursor((current_column_offset+6),current_line);
          printf("%c:",drive_lettering_buffer[drive-1] [drive_letter_index]);
          }
        else
          {
          Position_Cursor((current_column_offset+8),current_line);
          }

        /* Print size of logical drive */
        Position_Cursor((current_column_offset+10),current_line);

	if(drive_letter_index<4)
	  {
	  Print_UL(part_table[drive-1].pri_part[drive_letter_index].size_in_MB);
	  }
	else
	  {

	  Print_UL(part_table[drive-1].log_drive[(drive_letter_index-4)].size_in_MB);
	  }
	}

      drive_letter_index++;
      }while(drive_letter_index<27);

    /* Print amount of free space on drive */
    if(part_table[drive-1].total_hard_disk_size_in_MB>space_used_on_drive_in_MB)
      {
      Position_Cursor((current_column_offset_of_general_drive_information+18),current_line_of_general_drive_information);
      Print_UL(part_table[drive-1].total_hard_disk_size_in_MB-space_used_on_drive_in_MB);
      }

    /* Print drive usage percentage */
    if(space_used_on_drive_in_MB==0) usage=0;
    else
      {
      usage
       = Convert_To_Percentage(space_used_on_drive_in_MB,
       part_table[drive-1].total_hard_disk_size_in_MB);
      }

    Position_Cursor((current_column_offset_of_general_drive_information+28),current_line_of_general_drive_information);
    printf("%3d%%",usage);

    current_line++;
    drive++;
    }while(drive<=(flags.maximum_drive_number-127));

  printAt(4,20,"(1 Mbyte = 1048576 bytes)");
}

void Display_CL_Partition_Table()
{
  int index=0;

  unsigned long usage=0;
  Partition_Table *pDrive = &part_table[flags.drive_number-0x80];

  Determine_Drive_Letters();

  printf("\n\nCurrent fixed disk drive: %1d",(flags.drive_number-127));
  if(flags.extended_options_flag==TRUE)
    {
    printf("                  (TC: %4d",pDrive->total_cyl);
    printf(" TH: %3d",pDrive->total_head);
    printf(" TS: %3d)",pDrive->total_sect);
    }

  printf("\n\nPartition   Status   Mbytes   Description     Usage  ");
  if(flags.extended_options_flag==TRUE) printf("Start Cyl  End Cyl");
  printf("\n");

  index=0;
  do
    {
    if(pDrive->pri_part[index].num_type>0)
      {
      /* Drive Letter of Partition */
      if( IsRecognizedFatPartition(pDrive->pri_part[index].num_type))
        {
        printf(" %1c:",drive_lettering_buffer[(flags.drive_number-128)] [index]);
        }
      else printf("   ");

      /* Partition Number */
      printf(" %1d",(index+1));

      if(flags.extended_options_flag==TRUE)
        {
        /* Partition Type */
        printf(" %3d",(pDrive->pri_part[index].num_type));
        }
      else printf("    ");

      /* Status */
      if(pDrive->pri_part[index].active_status>0)
        {
        printf("      A");
	}
      else printf("       ");

      /* Mbytes */
      printf("    ");
      Print_UL(pDrive->pri_part[index].size_in_MB);

      /* Description */
      printf("   %15s",partition_lookup_table_buffer_long[pDrive->pri_part[index].num_type]);

      /* Usage */
      usage
       = Convert_To_Percentage(pDrive->pri_part[index].size_in_MB,
	pDrive->total_hard_disk_size_in_MB);

      printf("   %3d%%",usage);

      if(flags.extended_options_flag==TRUE)
        {
        /* Starting Cylinder */
        printf("    %4d",pDrive->pri_part[index].start_cyl);

        /* Ending Cylinder */
        printf("      %4d",pDrive->pri_part[index].end_cyl);
        }
      printf("\n");
      }

    index++;
    }while(index<4);

  /* Check to see if there are any drives to display */
  if( (brief_partition_table[(flags.drive_number-128)] [4]>0)
   || (brief_partition_table[(flags.drive_number-128)] [5]>0) )
    {
    printf("\nContents of Extended DOS Partition:\n");
    printf("Drv Volume Label  Mbytes  System  Usage\n");

    /* Display information for each Logical DOS Drive */
    index=4;
    do
      {
      if (brief_partition_table[(flags.drive_number-128)] [index] > 0)
	{
	if (IsRecognizedFatPartition(brief_partition_table[(flags.drive_number-128)] [index]))
	  {
	  /* Display drive letter */
	  printf(" %1c:",drive_lettering_buffer[(flags.drive_number-128)] [index]);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -