Subversion Repositories SvarDOS

Rev

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

Rev 421 Rev 518
Line 75... Line 75...
75
 
75
 
76
  /* convert path to canonical form */
76
  /* convert path to canonical form */
77
  file_truename(delspec, buff);
77
  file_truename(delspec, buff);
78
 
78
 
79
  /* is delspec pointing at a directory? if so, add a \*.* */
79
  /* is delspec pointing at a directory? if so, add a \*.* */
80
  { int attr = file_getattr(delspec);
80
  i = path_appendbkslash_if_dir(buff);
81
    if ((attr > 0) && (attr & DOS_ATTR_DIR)) strcat(buff, "\\????????.???");
81
  if (buff[i - 1] == '\\') strcat(buff, "????????.???");
82
  }
-
 
83
 
82
 
84
  /* parse delspec in buff and remember where last backslash or slash is */
83
  /* parse delspec in buff and remember where last backslash or slash is */
85
  for (i = 0; buff[i] != 0; i++) if (buff[i] == '\\') pathlimit = i + 1;
84
  for (i = 0; buff[i] != 0; i++) if (buff[i] == '\\') pathlimit = i + 1;
86
 
85
 
87
  /* is this about deleting all content inside a directory? if no per-file
86
  /* is this about deleting all content inside a directory? if no per-file
Line 94... Line 93...
94
  for (i = 0;; i = 1) {
93
  for (i = 0;; i = 1) {
95
 
94
 
96
    /* exec FindFirst or FindNext */
95
    /* exec FindFirst or FindNext */
97
    if (i == 0) {
96
    if (i == 0) {
98
      err = findfirst(dta, buff, DOS_ATTR_RO | DOS_ATTR_SYS | DOS_ATTR_HID);
97
      err = findfirst(dta, buff, DOS_ATTR_RO | DOS_ATTR_SYS | DOS_ATTR_HID);
-
 
98
      if (err != 0) { /* report the error only if query had no wildcards */
-
 
99
        for (i = 0; buff[i] != 0; i++) if (buff[i] == '?') break;
-
 
100
        if (buff[i] == 0) outputnl(doserr(err));
-
 
101
        break;
-
 
102
      }
99
    } else {
103
    } else {
100
      err = findnext(dta);
104
      if (findnext(dta) != 0) break; /* do not report errors on findnext() */
101
    }
105
    }
102
 
106
 
-
 
107
    /* prep the full path/name of the file in buff */
-
 
108
    /* NOTE: buff contained the search pattern but it is no longer needed so I
103
    if (err != 0) break;
109
     * can reuse it now */
-
 
110
    strcpy(buff + pathlimit, fname);
104
 
111
 
105
    /* ask if confirmation required: PLIK.TXT  Delete (Y/N)? */
112
    /* ask if confirmation required: PLIK.TXT  Delete (Y/N)? */
106
    if (confirmflag) {
113
    if (confirmflag) {
107
      strcpy(buff + pathlimit, fname); /* note: buff contained the search pattern but it no longer needed so I can reuse it now */
-
 
108
      output(buff);
114
      output(buff);
109
      output(" \t");
115
      output(" \t");
110
      if (askchoice("Delete (Y/N)?", "YN") != 0) continue;
116
      if (askchoice("Delete (Y/N)?", "YN") != 0) continue;
111
    }
117
    }
112
 
118
 
113
    /* del found file */
119
    /* del found file */
114
    _asm {
120
    _asm {
-
 
121
      push ax
-
 
122
      push dx
115
      mov ah, 0x41      /* delete a file, DS:DX points to an ASCIIZ filespec (no wildcards allowed) */
123
      mov ah, 0x41      /* delete a file, DS:DX points to an ASCIIZ filespec (no wildcards allowed) */
116
      mov dx, fname
124
      mov dx, buff
117
      int 0x21
125
      int 0x21
118
      jnc DONE
126
      jnc DONE
119
      mov [err], ax
127
      mov [err], ax
120
      DONE:
128
      DONE:
-
 
129
      pop dx
-
 
130
      pop ax
121
    }
131
    }
122
 
132
 
123
    if (err != 0) {
133
    if (err != 0) {
124
      output(fname);
134
      output(fname);
125
      output(": ");
135
      output(": ");
126
      outputnl(doserr(err));
136
      outputnl(doserr(err));
127
      break;
137
      break;
128
    }
138
    }
129
  }
139
  }
-
 
140
 
130
  return(-1);
141
  return(-1);
131
}
142
}