Subversion Repositories SvarDOS

Rev

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

Rev 1449 Rev 1450
Line 535... Line 535...
535
  cursor_left(db);
535
  cursor_left(db);
536
  del(db);
536
  del(db);
537
}
537
}
538
 
538
 
539
 
539
 
-
 
540
#define LOADFILE_FILENOTFOUND 2
-
 
541
 
540
/* returns 0 on success, 1 on file not found, 2 on other error */
542
/* returns 0 on success, 1 on file not found, 2 on other error */
541
static unsigned char loadfile(struct file *db, const char *fname) {
543
static unsigned char loadfile(struct file *db, const char *fname) {
542
  char buff[512]; /* read one entire sector at a time (faster) */
544
  char buff[512]; /* read one entire sector at a time (faster) */
543
  char *buffptr;
545
  char *buffptr;
544
  unsigned int len, llen;
546
  unsigned int len, llen;
Line 563... Line 565...
563
 
565
 
564
  if (fname == NULL) goto SKIPLOADING;
566
  if (fname == NULL) goto SKIPLOADING;
565
 
567
 
566
  mdr_dos_truename(db->fname, fname);
568
  mdr_dos_truename(db->fname, fname);
567
 
569
 
568
  if (_dos_open(fname, O_RDONLY, &fd) != 0) {
570
  err = _dos_open(fname, O_RDONLY, &fd);
569
    err = 1;
-
 
570
    goto SKIPLOADING;
571
  if (err != 0) goto SKIPLOADING;
571
  }
-
 
572
 
572
 
573
  db->lfonly = 1;
573
  db->lfonly = 1;
574
 
574
 
575
  for (eolfound = 0;;) {
575
  for (eolfound = 0;;) {
576
    unsigned short consumedbytes;
576
    unsigned short consumedbytes;
Line 648... Line 648...
648
 
648
 
649
  return(err);
649
  return(err);
650
 
650
 
651
  IOERR:
651
  IOERR:
652
  _dos_close(fd);
652
  _dos_close(fd);
653
  return(2);
653
  return(1);
654
}
654
}
655
 
655
 
656
 
656
 
657
/* a custom argv-parsing routine that looks directly inside the PSP, avoids the need
657
/* a custom argv-parsing routine that looks directly inside the PSP, avoids the need
658
 * of argc and argv, saves some 330 bytes of binary size
658
 * of argc and argv, saves some 330 bytes of binary size
Line 722... Line 722...
722
    mdr_coutraw_str(svarlang_str(1,2));
722
    mdr_coutraw_str(svarlang_str(1,2));
723
    mdr_coutraw_char(' ');
723
    mdr_coutraw_char(' ');
724
    mdr_coutraw_puts(arg);
724
    mdr_coutraw_puts(arg);
725
    err = loadfile(&(dbarr[count]), arg);
725
    err = loadfile(&(dbarr[count]), arg);
726
    if (err) {
726
    if (err) {
727
      if (err == 1) { /* file not found */
727
      if (err == LOADFILE_FILENOTFOUND) { /* file not found */
728
        if ((count == 0) && (lastarg != 0)) { /* a 'file not found' is fine if only one file was given */
728
        if ((count == 0) && (lastarg != 0)) { /* a 'file not found' is fine if only one file was given */
729
          err = 0;
729
          err = 0;
730
        } else {
730
        } else {
731
          err = 11;
731
          err = 11;
732
        }
732
        }
Line 1078... Line 1078...
1078
          ui_getstring(svarlang_str(0,7), fname, sizeof(fname));
1078
          ui_getstring(svarlang_str(0,7), fname, sizeof(fname));
1079
          if (fname[0] != 0) {
1079
          if (fname[0] != 0) {
1080
            unsigned char err;
1080
            unsigned char err;
1081
            err = loadfile(db, fname);
1081
            err = loadfile(db, fname);
1082
            if (err != 0) {
1082
            if (err != 0) {
1083
              if (err == 1) {
1083
              if (err == LOADFILE_FILENOTFOUND) {
1084
                ui_msg(svarlang_str(0,11), NULL, SCHEME_ERR); /* file not found */
1084
                ui_msg(svarlang_str(0,11), NULL, SCHEME_ERR); /* file not found */
1085
              } else {
1085
              } else {
1086
                ui_msg(svarlang_str(0,10), NULL, SCHEME_ERR);  /* ERROR */
1086
                ui_msg(svarlang_str(0,10), NULL, SCHEME_ERR);  /* ERROR */
1087
              }
1087
              }
1088
              mdr_bios_tickswait(44); /* 3s */
1088
              mdr_bios_tickswait(44); /* 3s */