changeset 294:797468042b32

fc-fsio: fwrite from file: handling of 0 length files implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sat, 01 Mar 2014 04:04:20 +0000
parents ffeea2f9d149
children 3dd74b16df82
files rvinterf/etmsync/fswrite.c
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/rvinterf/etmsync/fswrite.c	Sat Mar 01 03:53:49 2014 +0000
+++ b/rvinterf/etmsync/fswrite.c	Sat Mar 01 04:04:20 2014 +0000
@@ -172,10 +172,15 @@
 		}
 	}
 	fclose(srcf);
-	if (first)
-		return(0);
-	else
-		return fd_close(tfd);
+	if (first) {
+		/* 0 length file: do an open-for-write to create it */
+		rc = fd_open(pathname,
+				FFS_O_WRONLY | FFS_O_CREATE | FFS_O_TRUNC,
+				&tfd);
+		if (rc)
+			return(rc);
+	}
+	return fd_close(tfd);
 }
 
 cmd_fwrite(argc, argv)