Subversion Repositories SvarDOS

Rev

Rev 868 | Rev 908 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 868 Rev 898
Line 446... Line 446...
446
  fclose(fd);
446
  fclose(fd);
447
  return(0);
447
  return(0);
448
}
448
}
449
 
449
 
450
 
450
 
-
 
451
/* tries to write an empty file to drive.
-
 
452
 * asks DOS to inhibit the int 24h handler for this job, so erros are
-
 
453
 * gracefully reported - unfortunately this does not work under FreeDOS because
-
 
454
 * the DOS-C kernel does not implement the required flag.
-
 
455
 * returns 0 on success (ie. "disk exists and is writeable"). */
-
 
456
static unsigned short test_drive_write(char drive, char *buff) {
-
 
457
  unsigned short result = 0;
-
 
458
  sprintf(buff, "%c:\\SVWRTEST.123", drive);
-
 
459
  _asm {
-
 
460
    push ax
-
 
461
    push bx
-
 
462
    push cx
-
 
463
    push dx
-
 
464
 
-
 
465
    mov ah, 0x6c   /* extended open/create file */
-
 
466
    mov bx, 0x2001 /* open for write + inhibit int 24h handler */
-
 
467
    xor cx, cx     /* file attributes on the created file */
-
 
468
    mov dx, 0x0010 /* create file if does not exist, fail if it exists */
-
 
469
    mov si, buff   /* filename to create */
-
 
470
    int 0x21
-
 
471
    jc FAILURE
-
 
472
    /* close the file (handle in AX) */
-
 
473
    mov bx, ax
-
 
474
    mov ah, 0x3e /* close file */
-
 
475
    int 0x21
-
 
476
    jc FAILURE
-
 
477
    /* delete the file */
-
 
478
    mov ah, 0x41 /* delete file pointed out by DS:DX */
-
 
479
    mov dx, buff
-
 
480
    int 0x21
-
 
481
    jnc DONE
-
 
482
 
-
 
483
    FAILURE:
-
 
484
    mov result, ax
-
 
485
    DONE:
-
 
486
 
-
 
487
    pop dx
-
 
488
    pop cx
-
 
489
    pop bx
-
 
490
    pop ax
-
 
491
  }
-
 
492
  return(result);
-
 
493
}
-
 
494
 
-
 
495
 
451
static int preparedrive(char sourcedrv) {
496
static int preparedrive(char sourcedrv) {
452
  int driveremovable;
497
  int driveremovable;
453
  int selecteddrive = 3; /* default to 'C:' */
498
  int selecteddrive = 3; /* default to 'C:' */
454
  int cselecteddrive;
499
  int cselecteddrive;
455
  int ds;
500
  int ds;
Line 503... Line 548...
503
      video_putstring(9, 1, COLOR_BODY[mono], buff, -1);
548
      video_putstring(9, 1, COLOR_BODY[mono], buff, -1);
504
      putstringnls(11, 2, COLOR_BODY[mono], 0, 5); /* "Press any key..." */
549
      putstringnls(11, 2, COLOR_BODY[mono], 0, 5); /* "Press any key..." */
505
      return(MENUQUIT);
550
      return(MENUQUIT);
506
    }
551
    }
507
    /* if not formatted, propose to format it right away (try to create a directory) */
552
    /* if not formatted, propose to format it right away (try to create a directory) */
508
    snprintf(buff, sizeof(buff), "%c:\\SVWRTEST.123", cselecteddrive);
-
 
509
    if (mkdir(buff) == 0) {
553
    if (test_drive_write(cselecteddrive, buff) != 0) {
510
      rmdir(buff);
-
 
511
    } else {
-
 
512
      const char *list[3];
554
      const char *list[3];
513
      newscreen(0);
555
      newscreen(0);
514
      snprintf(buff, sizeof(buff), svarlang_str(3, 3), cselecteddrive); /* "ERROR: Drive %c: seems to be unformated. Do you wish to format it?") */
556
      snprintf(buff, sizeof(buff), svarlang_str(3, 3), cselecteddrive); /* "ERROR: Drive %c: seems to be unformated. Do you wish to format it?") */
515
      video_putstring(7, 1, COLOR_BODY[mono], buff, -1);
557
      video_putstring(7, 1, COLOR_BODY[mono], buff, -1);
516
 
558