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

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

Issue 10698011: Support posting of external data into dart as external uint8 arrays through the Dart API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years, 5 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_linux.cc ('k') | runtime/bin/file_win.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 #include <limits.h> 12 #include <limits.h>
13 13
14 #include "bin/builtin.h" 14 #include "bin/builtin.h"
15 15
16 class FileHandle { 16 class FileHandle {
17 public: 17 public:
18 explicit FileHandle(int fd) : fd_(fd) { } 18 explicit FileHandle(int fd) : fd_(fd) { }
19 ~FileHandle() { } 19 ~FileHandle() { }
20 int fd() const { return fd_; } 20 int fd() const { return fd_; }
21 void set_fd(int fd) { fd_ = fd; } 21 void set_fd(int fd) { fd_ = fd; }
22 22
23 private: 23 private:
24 int fd_; 24 int fd_;
25 25
26 // DISALLOW_COPY_AND_ASSIGN(FileHandle). 26 DISALLOW_COPY_AND_ASSIGN(FileHandle);
27 FileHandle(const FileHandle&);
28 void operator=(const FileHandle&);
29 }; 27 };
30 28
31 29
32 File::~File() { 30 File::~File() {
33 // Close the file (unless it's a standard stream). 31 // Close the file (unless it's a standard stream).
34 if (handle_->fd() > STDERR_FILENO) { 32 if (handle_->fd() > STDERR_FILENO) {
35 Close(); 33 Close();
36 } 34 }
37 delete handle_; 35 delete handle_;
38 } 36 }
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 int result = fstat(fd, &buf); 240 int result = fstat(fd, &buf);
243 if (result == -1) { 241 if (result == -1) {
244 FATAL2("Failed stat on file descriptor %d: %s", fd, strerror(errno)); 242 FATAL2("Failed stat on file descriptor %d: %s", fd, strerror(errno));
245 } 243 }
246 if (S_ISCHR(buf.st_mode)) return kTerminal; 244 if (S_ISCHR(buf.st_mode)) return kTerminal;
247 if (S_ISFIFO(buf.st_mode)) return kPipe; 245 if (S_ISFIFO(buf.st_mode)) return kPipe;
248 if (S_ISSOCK(buf.st_mode)) return kSocket; 246 if (S_ISSOCK(buf.st_mode)) return kSocket;
249 if (S_ISREG(buf.st_mode)) return kFile; 247 if (S_ISREG(buf.st_mode)) return kFile;
250 return kOther; 248 return kOther;
251 } 249 }
OLDNEW
« no previous file with comments | « runtime/bin/file_linux.cc ('k') | runtime/bin/file_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698