Subversion Repositories SvarDOS

Rev

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

Rev 518 Rev 533
Line 24... Line 24...
24
 
24
 
25
/*
25
/*
26
 * del/erase
26
 * del/erase
27
 */
27
 */
28
 
28
 
29
static int cmd_del(struct cmd_funcparam *p) {
29
static enum cmd_result cmd_del(struct cmd_funcparam *p) {
30
  const char *delspec = NULL;
30
  const char *delspec = NULL;
31
  unsigned short err = 0;
31
  unsigned short err = 0;
32
  unsigned short confirmflag = 0;
32
  unsigned short confirmflag = 0;
33
  unsigned short i;
33
  unsigned short i;
34
  unsigned short pathlimit = 0;
34
  unsigned short pathlimit = 0;
Line 43... Line 43...
43
    outputnl("DEL [drive:][path]filename [/P]");
43
    outputnl("DEL [drive:][path]filename [/P]");
44
    outputnl("ERASE [drive:][path]filename [/P]");
44
    outputnl("ERASE [drive:][path]filename [/P]");
45
    outputnl("");
45
    outputnl("");
46
    outputnl("[drive:][path]filename  Specifies the file(s) to delete.");
46
    outputnl("[drive:][path]filename  Specifies the file(s) to delete.");
47
    outputnl("/P  Prompts for confirmation before deleting each file.");
47
    outputnl("/P  Prompts for confirmation before deleting each file.");
48
    return(-1);
48
    return(CMD_OK);
49
  }
49
  }
50
 
50
 
51
  if (p->argc == 0) {
51
  if (p->argc == 0) {
52
    outputnl("Required parameter missing");
52
    outputnl("Required parameter missing");
53
    return(-1);
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? */
Line 61... Line 61...
61
        confirmflag = 1;
61
        confirmflag = 1;
62
      } else {
62
      } else {
63
        output("Invalid switch:");
63
        output("Invalid switch:");
64
        output(" ");
64
        output(" ");
65
        outputnl(p->argv[i]);
65
        outputnl(p->argv[i]);
66
        return(-1);
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
      outputnl("Too many parameters");
70
      return(-1);
70
      return(CMD_FAIL);
71
    } else {
71
    } else {
72
      delspec = p->argv[i];
72
      delspec = p->argv[i];
73
    }
73
    }
74
  }
74
  }
75
 
75
 
Line 85... Line 85...
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
    outputnl("All files in directory will be deleted!");
90
    if (askchoice("Are you sure (Y/N)?", "YN") != 0) return(-1);
90
    if (askchoice("Are you sure (Y/N)?", "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 136... Line 136...
136
      outputnl(doserr(err));
136
      outputnl(doserr(err));
137
      break;
137
      break;
138
    }
138
    }
139
  }
139
  }
140
 
140
 
-
 
141
  if (err == 0) return(CMD_OK);
141
  return(-1);
142
  return(CMD_FAIL);
142
}
143
}