aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--mpio_tool/mpiosh.c62
-rw-r--r--mpio_tool/mpiosh.h3
3 files changed, 66 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 9eab880..d98f689 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2002-09-11 Markus Germeier <mager@tzi.de>
+ * mpio_tool/mpiosh.c (mpiosh_cmd_mdel): added command mdel
+
+2002-09-11 Markus Germeier <mager@tzi.de>
+
* libmpio/mpio.c (mpio_file_put):
finished support for writing to internal memory
+ changes to fat.c and io.c
diff --git a/mpio_tool/mpiosh.c b/mpio_tool/mpiosh.c
index f2ac672..a364422 100644
--- a/mpio_tool/mpiosh.c
+++ b/mpio_tool/mpiosh.c
@@ -2,7 +2,7 @@
/*
*
- * $Id: mpiosh.c,v 1.7 2002/09/08 22:57:22 germeier Exp $
+ * $Id: mpiosh.c,v 1.8 2002/09/11 13:59:21 germeier Exp $
*
* Author: Andreas Büsching <crunchy@tzi.de>
*
@@ -61,6 +61,7 @@ static mpiosh_cmd_t commands[] = {
{ "put", mpiosh_cmd_put, YES },
{ "mput", mpiosh_cmd_mput, YES },
{ "del", mpiosh_cmd_del, YES },
+ { "mdel", mpiosh_cmd_mdel, YES },
{ "dump", mpiosh_cmd_dump, NO },
{ "free", mpiosh_cmd_free, NO },
{ "format", mpiosh_cmd_format, NO },
@@ -310,11 +311,14 @@ mpiosh_cmd_help(char *args[])
" to the selected memory card\n");
printf("get <filename>\n"
" read <filename> from memory card\n");
- printf("mput <regexp>\n"
+ printf("mget <regexp>\n"
" read all files matching the regular expression\n"
" from the selected memory card\n");
printf("del <filename>\n"
" deletes <filename> from memory card\n");
+ printf("mdel <regexp>\n"
+ " deletes all files matching the regular expression\n"
+ " from the selected memory card\n");
printf("exit, quit\n"
" exit mpiosh and close the device\n");
printf("lcd\n"
@@ -636,6 +640,60 @@ mpiosh_cmd_del(char *args[])
printf("\n");
}
+void
+mpiosh_cmd_mdel(char *args[])
+{
+ BYTE * p;
+ int size, i = 0;
+ int error;
+ regex_t regex;
+ BYTE fname[100];
+ BYTE errortext[100];
+ BYTE month, day, hour, minute;
+ WORD year;
+ DWORD fsize;
+
+ if (mpiosh.dev == NULL) {
+ printf("connection to MPIO player already closed\n");
+ return;
+ }
+
+ if (args[0] == NULL) {
+ printf("error: no argument given\n");
+ return;
+ }
+
+ while (args[i] != NULL) {
+ if (error = regcomp(&regex, args[i], REG_NOSUB)) {
+ regerror(error, &regex, errortext, 100);
+ debugn (2, "error in regular expression: %s (%s)\n", args[i], errortext);
+ } else {
+ p = mpio_directory_open(mpiosh.dev, mpiosh.card);
+ while (p != NULL) {
+ memset(fname, '\0', 100);
+ mpio_dentry_get(mpiosh.dev, p, fname, 100,
+ &year, &month, &day, &hour, &minute, &fsize);
+
+ if (!(error = regexec(&regex, fname, 0, NULL, 0))) {
+ printf("deleting '%s' ... \n", fname);
+ size = mpio_file_del(mpiosh.dev, mpiosh.card,
+ fname, mpiosh_callback_del);
+ printf("\n");
+ /* if we delete a file, start again from the beginning,
+ because the directory has changed !! */
+ p = mpio_directory_open(mpiosh.dev, mpiosh.card);
+ } else {
+ regerror(error, &regex, errortext, 100);
+ debugn (2, "file does not match: %s (%s)\n", fname, errortext);
+ p = mpio_dentry_next(mpiosh.dev, p);
+ }
+
+ }
+ }
+ i++;
+ }
+}
+
void
mpiosh_cmd_dump(char *args[])
diff --git a/mpio_tool/mpiosh.h b/mpio_tool/mpiosh.h
index 9f9b297..6e5f8de 100644
--- a/mpio_tool/mpiosh.h
+++ b/mpio_tool/mpiosh.h
@@ -2,7 +2,7 @@
*
* Author: Andreas Büsching <crunchy@tzi.de>
*
- * $Id: mpiosh.h,v 1.4 2002/09/04 07:55:08 crunchy Exp $
+ * $Id: mpiosh.h,v 1.5 2002/09/11 13:59:21 germeier Exp $
*
* Copyright (C) 2002 Andreas Büsching <crunchy@tzi.de>
*
@@ -76,6 +76,7 @@ void mpiosh_cmd_mget(char *args[]);
void mpiosh_cmd_put(char *args[]);
void mpiosh_cmd_mput(char *args[]);
void mpiosh_cmd_del(char *args[]);
+void mpiosh_cmd_mdel(char *args[]);
void mpiosh_cmd_dump(char *args[]);
void mpiosh_cmd_free(char *args[]);
void mpiosh_cmd_format(char *args[]);