diff rvinterf/etmsync/fsupload.c @ 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 0242d5facf7b
children
line wrap: on
line diff
--- 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]);
+}