changeset 299:91570f916dd3

fc-fsio: upload-file and upload-subtree implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 02 Mar 2014 01:09:30 +0000
parents 100192a92472
children 19b846c8abed
files rvinterf/etmsync/fscmdtab.c rvinterf/etmsync/fsupload.c
diffstat 2 files changed, 38 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/rvinterf/etmsync/fscmdtab.c	Sun Mar 02 00:39:56 2014 +0000
+++ b/rvinterf/etmsync/fscmdtab.c	Sun Mar 02 01:09:30 2014 +0000
@@ -18,6 +18,8 @@
 extern int cmd_mkdir();
 extern int cmd_stat();
 extern int cmd_uploadfs();
+extern int cmd_upload_file();
+extern int cmd_upload_subtree();
 
 struct cmdtab cmdtab[] = {
 	{"cpout", 2, 2, cmd_cpout},
@@ -33,6 +35,8 @@
 	{"ls", 1, 1, cmd_ls},
 	{"mkdir", 1, 1, cmd_mkdir},
 	{"stat", 1, 1, cmd_stat},
+	{"upload-file", 2, 2, cmd_upload_file},
 	{"upload-fs", 1, 1, cmd_uploadfs},
+	{"upload-subtree", 2, 2, cmd_upload_subtree},
 	{0, 0, 0, 0}
 };
--- a/rvinterf/etmsync/fsupload.c	Sun Mar 02 00:39:56 2014 +0000
+++ b/rvinterf/etmsync/fsupload.c	Sun Mar 02 01:09:30 2014 +0000
@@ -110,3 +110,37 @@
 {
 	return uploadfs_level(argv[1], 0, "");
 }
+
+cmd_upload_file(argc, argv)
+	char **argv;
+{
+	if (strlen(argv[2]) >= TMFFS_STRING_SIZE) {
+		fprintf(stderr,
+			"error: pathname arg exceeds string length limit\n");
+		return(ERROR_USAGE);
+	}
+	return fwrite_from_file(argv[2], argv[1]);
+}
+
+cmd_upload_subtree(argc, argv)
+	char **argv;
+{
+	int rc, depth;
+
+	depth = validate_ffs_pathname(argv[2]);
+	if (depth < 0)
+		return(ERROR_USAGE);	/* error msg already printed */
+	if (depth == 0) {
+		fprintf(stderr, "please use upload-fs command instead\n");
+		return(ERROR_USAGE);
+	}
+	if (depth >= MAX_NAME_DEPTH) {
+		fprintf(stderr, "cannot upload into max-depth directory\n");
+		return(ERROR_USAGE);
+	}
+	printf("mkdir %s\n", argv[2]);
+	rc = do_mkdir_existok(argv[2]);
+	if (rc)
+		return(rc);
+	return uploadfs_level(argv[1], depth, argv[2]);
+}