Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(423)

Unified Diff: host/lib/host_misc.c

Issue 2748008: Add vbutil_keyblock (Closed) Base URL: ssh://gitrw.chromium.org/vboot_reference.git
Patch Set: Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « host/lib/host_key.c ('k') | host/linktest/main.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: host/lib/host_misc.c
diff --git a/host/lib/host_misc.c b/host/lib/host_misc.c
index f24bf40dc0159973848e872c7749a215642b3ee9..2620df7a98e444ebdd3e96e20277019c112768c5 100644
--- a/host/lib/host_misc.c
+++ b/host/lib/host_misc.c
@@ -9,6 +9,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <unistd.h>
#include "host_common.h"
@@ -47,3 +48,21 @@ uint8_t* ReadFile(const char* filename, uint64_t* size) {
fclose(f);
return buf;
}
+
+
+int WriteFile(const char* filename, const void *data, uint64_t size) {
+ FILE *f = fopen(filename, "wb");
+ if (!f) {
+ debug("Unable to open file %s\n", filename);
+ return 1;
+ }
+
+ if (1 != fwrite(data, size, 1, f)) {
+ debug("Unable to write to file %s\n", filename);
+ fclose(f);
+ unlink(filename); /* Delete any partial file */
+ }
+
+ fclose(f);
+ return 0;
+}
« no previous file with comments | « host/lib/host_key.c ('k') | host/linktest/main.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698