| OLD | NEW |
| 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 <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <io.h> | 8 #include <io.h> |
| 9 #include <stdio.h> | 9 #include <stdio.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| 11 #include <sys/stat.h> | 11 #include <sys/stat.h> |
| 12 | 12 |
| 13 #include "bin/builtin.h" | 13 #include "bin/builtin.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 FileHandle(const FileHandle&); | |
| 27 void operator=(const FileHandle&); | |
| 28 }; | 26 }; |
| 29 | 27 |
| 30 | 28 |
| 31 File::~File() { | 29 File::~File() { |
| 32 // Close the file (unless it's a standard stream). | 30 // Close the file (unless it's a standard stream). |
| 33 if (handle_->fd() > 2) { | 31 if (handle_->fd() > 2) { |
| 34 Close(); | 32 Close(); |
| 35 } | 33 } |
| 36 delete handle_; | 34 delete handle_; |
| 37 } | 35 } |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 const char* File::StringEscapedPathSeparator() { | 225 const char* File::StringEscapedPathSeparator() { |
| 228 return "\\\\"; | 226 return "\\\\"; |
| 229 } | 227 } |
| 230 | 228 |
| 231 | 229 |
| 232 File::StdioHandleType File::GetStdioHandleType(int fd) { | 230 File::StdioHandleType File::GetStdioHandleType(int fd) { |
| 233 // Treat all stdio handles as pipes. The Windows event handler and | 231 // Treat all stdio handles as pipes. The Windows event handler and |
| 234 // socket code will handle the different handle types. | 232 // socket code will handle the different handle types. |
| 235 return kPipe; | 233 return kPipe; |
| 236 } | 234 } |
| OLD | NEW |