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

Side by Side Diff: runtime/bin/file_linux.cc

Issue 9839053: Add error handling to random access file (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased to r5810 Created 8 years, 9 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 | « runtime/bin/file_impl.dart ('k') | runtime/bin/file_macos.cc » ('j') | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "bin/file.h" 5 #include "bin/file.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 #include <unistd.h> 10 #include <unistd.h>
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 return TEMP_FAILURE_RETRY(lseek(handle_->fd(), position, SEEK_SET) != -1); 78 return TEMP_FAILURE_RETRY(lseek(handle_->fd(), position, SEEK_SET) != -1);
79 } 79 }
80 80
81 81
82 bool File::Truncate(int64_t length) { 82 bool File::Truncate(int64_t length) {
83 ASSERT(handle_->fd() >= 0); 83 ASSERT(handle_->fd() >= 0);
84 return TEMP_FAILURE_RETRY(ftruncate(handle_->fd(), length) != -1); 84 return TEMP_FAILURE_RETRY(ftruncate(handle_->fd(), length) != -1);
85 } 85 }
86 86
87 87
88 void File::Flush() { 88 bool File::Flush() {
89 ASSERT(handle_->fd() >= 0); 89 ASSERT(handle_->fd() >= 0);
90 TEMP_FAILURE_RETRY(fsync(handle_->fd())); 90 return TEMP_FAILURE_RETRY(fsync(handle_->fd()) != -1);
91 } 91 }
92 92
93 93
94 off_t File::Length() { 94 off_t File::Length() {
95 ASSERT(handle_->fd() >= 0); 95 ASSERT(handle_->fd() >= 0);
96 off_t position = TEMP_FAILURE_RETRY(lseek(handle_->fd(), 0, SEEK_CUR)); 96 off_t position = TEMP_FAILURE_RETRY(lseek(handle_->fd(), 0, SEEK_CUR));
97 if (position < 0) { 97 if (position < 0) {
98 // The file is not capable of seeking. Return an error. 98 // The file is not capable of seeking. Return an error.
99 return -1; 99 return -1;
100 } 100 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 int result = fstat(fd, &buf); 220 int result = fstat(fd, &buf);
221 if (result == -1) { 221 if (result == -1) {
222 FATAL2("Failed stat on file descriptor %d: %s", fd, strerror(errno)); 222 FATAL2("Failed stat on file descriptor %d: %s", fd, strerror(errno));
223 } 223 }
224 if (S_ISCHR(buf.st_mode)) return kTerminal; 224 if (S_ISCHR(buf.st_mode)) return kTerminal;
225 if (S_ISFIFO(buf.st_mode)) return kPipe; 225 if (S_ISFIFO(buf.st_mode)) return kPipe;
226 if (S_ISSOCK(buf.st_mode)) return kSocket; 226 if (S_ISSOCK(buf.st_mode)) return kSocket;
227 if (S_ISREG(buf.st_mode)) return kFile; 227 if (S_ISREG(buf.st_mode)) return kFile;
228 return kOther; 228 return kOther;
229 } 229 }
OLDNEW
« no previous file with comments | « runtime/bin/file_impl.dart ('k') | runtime/bin/file_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698