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

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

Issue 11312242: Revised CL for customisable logging (replacing printfs). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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/eventhandler_win.cc ('k') | runtime/bin/file_linux.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>
11 #include <libgen.h> 11 #include <libgen.h>
12 12
13 #include "bin/builtin.h" 13 #include "bin/builtin.h"
14 #include "bin/log.h"
14 15
15 class FileHandle { 16 class FileHandle {
16 public: 17 public:
17 explicit FileHandle(int fd) : fd_(fd) { } 18 explicit FileHandle(int fd) : fd_(fd) { }
18 ~FileHandle() { } 19 ~FileHandle() { }
19 int fd() const { return fd_; } 20 int fd() const { return fd_; }
20 void set_fd(int fd) { fd_ = fd; } 21 void set_fd(int fd) { fd_ = fd; }
21 22
22 private: 23 private:
23 int fd_; 24 int fd_;
(...skipping 11 matching lines...) Expand all
35 } 36 }
36 37
37 38
38 void File::Close() { 39 void File::Close() {
39 ASSERT(handle_->fd() >= 0); 40 ASSERT(handle_->fd() >= 0);
40 int err = TEMP_FAILURE_RETRY(close(handle_->fd())); 41 int err = TEMP_FAILURE_RETRY(close(handle_->fd()));
41 if (err != 0) { 42 if (err != 0) {
42 const int kBufferSize = 1024; 43 const int kBufferSize = 1024;
43 char error_message[kBufferSize]; 44 char error_message[kBufferSize];
44 strerror_r(errno, error_message, kBufferSize); 45 strerror_r(errno, error_message, kBufferSize);
45 fprintf(stderr, "%s\n", error_message); 46 Log::PrintErr("%s\n", error_message);
46 } 47 }
47 handle_->set_fd(kClosedFd); 48 handle_->set_fd(kClosedFd);
48 } 49 }
49 50
50 51
51 bool File::IsClosed() { 52 bool File::IsClosed() {
52 return handle_->fd() == kClosedFd; 53 return handle_->fd() == kClosedFd;
53 } 54 }
54 55
55 56
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 int result = fstat(fd, &buf); 235 int result = fstat(fd, &buf);
235 if (result == -1) { 236 if (result == -1) {
236 FATAL2("Failed stat on file descriptor %d: %s", fd, strerror(errno)); 237 FATAL2("Failed stat on file descriptor %d: %s", fd, strerror(errno));
237 } 238 }
238 if (S_ISCHR(buf.st_mode)) return kTerminal; 239 if (S_ISCHR(buf.st_mode)) return kTerminal;
239 if (S_ISFIFO(buf.st_mode)) return kPipe; 240 if (S_ISFIFO(buf.st_mode)) return kPipe;
240 if (S_ISSOCK(buf.st_mode)) return kSocket; 241 if (S_ISSOCK(buf.st_mode)) return kSocket;
241 if (S_ISREG(buf.st_mode)) return kFile; 242 if (S_ISREG(buf.st_mode)) return kFile;
242 return kOther; 243 return kOther;
243 } 244 }
OLDNEW
« no previous file with comments | « runtime/bin/eventhandler_win.cc ('k') | runtime/bin/file_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698