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

Side by Side Diff: split_write.cc

Issue 6693050: memento_softwareupdate: fix split_write error "bad file descriptor" (Closed) Base URL: ssh://gitrw.chromium.org:9222/memento_softwareupdate.git@master
Patch Set: Created 9 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <sys/stat.h> 5 #include <sys/stat.h>
6 #include <sys/types.h> 6 #include <sys/types.h>
7 7
8 #include <endian.h> 8 #include <endian.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 } 70 }
71 71
72 // Returns valid fd or exits program. 72 // Returns valid fd or exits program.
73 int open_file(const char* path) { 73 int open_file(const char* path) {
74 int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0666); 74 int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0666);
75 if (fd < 0) { 75 if (fd < 0) {
76 perror("open"); 76 perror("open");
77 fprintf(stderr, "failed to open %s\n", path); 77 fprintf(stderr, "failed to open %s\n", path);
78 exit(1); 78 exit(1);
79 } 79 }
80 return fd;
80 } 81 }
81 82
82 typedef long long int64; 83 typedef long long int64;
83 // Compile assert sizeof(int64) == 8: 84 // Compile assert sizeof(int64) == 8:
84 char int64_8_bytes_long[(sizeof(int64) == 8) - 1]; 85 char int64_8_bytes_long[(sizeof(int64) == 8) - 1];
85 86
86 } // namespace {} 87 } // namespace {}
87 88
88 int main(int argc, char** argv) { 89 int main(int argc, char** argv) {
89 if (argc != 3) { 90 if (argc != 3) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 } 129 }
129 // Do the rest on the second file 130 // Do the rest on the second file
130 for (;;) { 131 for (;;) {
131 size_t chunk_size = read_all(fd_in, buf, kBufSize); 132 size_t chunk_size = read_all(fd_in, buf, kBufSize);
132 if (chunk_size == 0) 133 if (chunk_size == 0)
133 break; 134 break;
134 write_all(fd2, buf, chunk_size); 135 write_all(fd2, buf, chunk_size);
135 } 136 }
136 return 0; 137 return 0;
137 } 138 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698