Subversion Repositories SvarDOS

Rev

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

Rev 538 Rev 990
Line 1... Line 1...
1
/* This file is part of the SvarCOM project and is published under the terms
1
/* This file is part of the SvarCOM project and is published under the terms
2
 * of the MIT license.
2
 * of the MIT license.
3
 *
3
 *
4
 * Copyright (C) 2021 Mateusz Viste
4
 * Copyright (C) 2021-2022 Mateusz Viste
5
 *
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a
6
 * Permission is hereby granted, free of charge, to any person obtaining a
7
 * copy of this software and associated documentation files (the "Software"),
7
 * copy of this software and associated documentation files (the "Software"),
8
 * to deal in the Software without restriction, including without limitation
8
 * to deal in the Software without restriction, including without limitation
9
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
Line 36... Line 36...
36
 
36
 
37
  struct DTA *dta = (void *)0x80; /* use the default DTA at location 80h in PSP */
37
  struct DTA *dta = (void *)0x80; /* use the default DTA at location 80h in PSP */
38
  char *fname = dta->fname;
38
  char *fname = dta->fname;
39
 
39
 
40
  if (cmd_ishlp(p)) {
40
  if (cmd_ishlp(p)) {
41
    outputnl("Deletes one or more files.");
41
    nls_outputnl(36,0); /* "Deletes one or more files." */
42
    outputnl("");
42
    outputnl("");
43
    outputnl("DEL [drive:][path]filename [/P]");
43
    nls_outputnl(36,1); /* "DEL [drive:][path]filename [/P]" */
44
    outputnl("ERASE [drive:][path]filename [/P]");
44
    nls_outputnl(36,2); /* "ERASE [drive:][path]filename [/P]" */
45
    outputnl("");
45
    outputnl("");
46
    outputnl("[drive:][path]filename  Specifies the file(s) to delete.");
46
    nls_outputnl(36,3); /* "[drive:][path]filename  Specifies the file(s) to delete." */
47
    outputnl("/P  Prompts for confirmation before deleting each file.");
47
    nls_outputnl(36,4); /* "/P  Prompts for confirmation before deleting each file." */
48
    return(CMD_OK);
48
    return(CMD_OK);
49
  }
49
  }
50
 
50
 
51
  if (p->argc == 0) {
51
  if (p->argc == 0) {
52
    outputnl("Required parameter missing");
52
    nls_outputnl(0,7); /* "Required parameter missing" */
53
    return(CMD_FAIL);
53
    return(CMD_FAIL);
54
  }
54
  }
55
 
55
 
56
  /* scan argv for delspec and possible /p or /v */
56
  /* scan argv for delspec and possible /p or /v */
57
  for (i = 0; i < p->argc; i++) {
57
  for (i = 0; i < p->argc; i++) {
58
    /* delspec? */
58
    /* delspec? */
59
    if (p->argv[i][0] == '/') {
59
    if (p->argv[i][0] == '/') {
60
      if (imatch(p->argv[i], "/p")) {
60
      if (imatch(p->argv[i], "/p")) {
61
        confirmflag = 1;
61
        confirmflag = 1;
62
      } else {
62
      } else {
63
        output("Invalid switch:");
63
        nls_output(0,2); /* "Invalid switch" */
64
        output(" ");
64
        output(": ");
65
        outputnl(p->argv[i]);
65
        outputnl(p->argv[i]);
66
        return(CMD_FAIL);
66
        return(CMD_FAIL);
67
      }
67
      }
68
    } else if (delspec != NULL) { /* otherwise its a delspec */
68
    } else if (delspec != NULL) { /* otherwise its a delspec */
69
      outputnl("Too many parameters");
69
      nls_outputnl(0,4); /* "Too many parameters" */
70
      return(CMD_FAIL);
70
      return(CMD_FAIL);
71
    } else {
71
    } else {
72
      delspec = p->argv[i];
72
      delspec = p->argv[i];
73
    }
73
    }
74
  }
74
  }
Line 84... Line 84...
84
  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;
85
 
85
 
86
  /* 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
87
   * confirmation set, ask for a global confirmation */
87
   * confirmation set, ask for a global confirmation */
88
  if ((confirmflag == 0) && (imatch(buff + pathlimit, "????????.???"))) {
88
  if ((confirmflag == 0) && (imatch(buff + pathlimit, "????????.???"))) {
89
    outputnl("All files in directory will be deleted!");
89
    nls_outputnl(36,5); /* "All files in directory will be deleted!" */
90
    if (askchoice("Are you sure (Y/N)?", "YN") != 0) return(CMD_FAIL);
90
    if (askchoice(svarlang_str(36,6)/*"Are you sure (Y/N)?"*/, svarlang_str(0,10)/*"YN"*/) != 0) return(CMD_FAIL);
91
  }
91
  }
92
 
92
 
93
  for (i = 0;; i = 1) {
93
  for (i = 0;; i = 1) {
94
 
94
 
95
    /* exec FindFirst or FindNext */
95
    /* exec FindFirst or FindNext */
Line 111... Line 111...
111
 
111
 
112
    /* ask if confirmation required: PLIK.TXT  Delete (Y/N)? */
112
    /* ask if confirmation required: PLIK.TXT  Delete (Y/N)? */
113
    if (confirmflag) {
113
    if (confirmflag) {
114
      output(buff);
114
      output(buff);
115
      output(" \t");
115
      output(" \t");
116
      if (askchoice("Delete (Y/N)?", "YN") != 0) continue;
116
      if (askchoice(svarlang_str(36,7)/*"Delete (Y/N)?"*/, svarlang_str(0,10)) != 0) continue;
117
    }
117
    }
118
 
118
 
119
    /* del found file */
119
    /* del found file */
120
    _asm {
120
    _asm {
121
      push ax
121
      push ax