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

Side by Side Diff: runtime/bin/file_win.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
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"
Ivan Posva 2012/11/15 07:43:17 Where did the include of file.h go? And how can th
gram 2012/11/15 21:16:50 Not sure what happened here; it is restored now.
6
7 #include <fcntl.h> 5 #include <fcntl.h>
8 #include <io.h> 6 #include <io.h>
9 #include <stdio.h> 7 #include <stdio.h>
10 #include <string.h> 8 #include <string.h>
11 #include <sys/stat.h> 9 #include <sys/stat.h>
12 10
11 #include "bin/platform.h"
siva 2012/11/15 18:46:48 Why does this need to be included here now, it was
gram 2012/11/15 21:16:50 Removed
13 #include "bin/builtin.h" 12 #include "bin/builtin.h"
13 #include "bin/log.h"
14 14
15 class FileHandle { 15 class FileHandle {
16 public: 16 public:
17 explicit FileHandle(int fd) : fd_(fd) { } 17 explicit FileHandle(int fd) : fd_(fd) { }
18 ~FileHandle() { } 18 ~FileHandle() { }
19 int fd() const { return fd_; } 19 int fd() const { return fd_; }
20 void set_fd(int fd) { fd_ = fd; } 20 void set_fd(int fd) { fd_ = fd; }
21 21
22 private: 22 private:
23 int fd_; 23 int fd_;
24 24
25 DISALLOW_COPY_AND_ASSIGN(FileHandle); 25 DISALLOW_COPY_AND_ASSIGN(FileHandle);
26 }; 26 };
27 27
28 28
29 File::~File() { 29 File::~File() {
30 // Close the file (unless it's a standard stream). 30 // Close the file (unless it's a standard stream).
31 if (handle_->fd() > 2) { 31 if (handle_->fd() > 2) {
32 Close(); 32 Close();
33 } 33 }
34 delete handle_; 34 delete handle_;
35 } 35 }
36 36
37 37
38 void File::Close() { 38 void File::Close() {
39 ASSERT(handle_->fd() >= 0); 39 ASSERT(handle_->fd() >= 0);
40 int err = close(handle_->fd()); 40 int err = close(handle_->fd());
41 if (err != 0) { 41 if (err != 0) {
42 fprintf(stderr, "%s\n", strerror(errno)); 42 Log::PrintErr("%s\n", strerror(errno));
43 } 43 }
44 handle_->set_fd(kClosedFd); 44 handle_->set_fd(kClosedFd);
45 } 45 }
46 46
47 47
48 bool File::IsClosed() { 48 bool File::IsClosed() {
49 return handle_->fd() == kClosedFd; 49 return handle_->fd() == kClosedFd;
50 } 50 }
51 51
52 52
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 const char* File::StringEscapedPathSeparator() { 254 const char* File::StringEscapedPathSeparator() {
255 return "\\\\"; 255 return "\\\\";
256 } 256 }
257 257
258 258
259 File::StdioHandleType File::GetStdioHandleType(int fd) { 259 File::StdioHandleType File::GetStdioHandleType(int fd) {
260 // Treat all stdio handles as pipes. The Windows event handler and 260 // Treat all stdio handles as pipes. The Windows event handler and
261 // socket code will handle the different handle types. 261 // socket code will handle the different handle types.
262 return kPipe; 262 return kPipe;
263 } 263 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698