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

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

Issue 11348006: Remove file name from File C++ structure. It is not used. (Closed) Base URL: https://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/file_linux.cc ('k') | runtime/bin/file_test.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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 int fd = TEMP_FAILURE_RETRY(open(name, flags, 0666)); 119 int fd = TEMP_FAILURE_RETRY(open(name, flags, 0666));
120 if (fd < 0) { 120 if (fd < 0) {
121 return NULL; 121 return NULL;
122 } 122 }
123 if (((mode & kWrite) != 0) && ((mode & kTruncate) == 0)) { 123 if (((mode & kWrite) != 0) && ((mode & kTruncate) == 0)) {
124 int position = TEMP_FAILURE_RETRY(lseek(fd, 0, SEEK_END)); 124 int position = TEMP_FAILURE_RETRY(lseek(fd, 0, SEEK_END));
125 if (position < 0) { 125 if (position < 0) {
126 return NULL; 126 return NULL;
127 } 127 }
128 } 128 }
129 return new File(name, new FileHandle(fd)); 129 return new File(new FileHandle(fd));
130 } 130 }
131 131
132 132
133 File* File::OpenStdio(int fd) { 133 File* File::OpenStdio(int fd) {
134 if (fd < 0 || 2 < fd) return NULL; 134 if (fd < 0 || 2 < fd) return NULL;
135 return new File(NULL, new FileHandle(fd)); 135 return new File(new FileHandle(fd));
136 } 136 }
137 137
138 138
139 bool File::Exists(const char* name) { 139 bool File::Exists(const char* name) {
140 struct stat st; 140 struct stat st;
141 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { 141 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) {
142 return S_ISREG(st.st_mode); 142 return S_ISREG(st.st_mode);
143 } else { 143 } else {
144 return false; 144 return false;
145 } 145 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 int result = fstat(fd, &buf); 240 int result = fstat(fd, &buf);
241 if (result == -1) { 241 if (result == -1) {
242 FATAL2("Failed stat on file descriptor %d: %s", fd, strerror(errno)); 242 FATAL2("Failed stat on file descriptor %d: %s", fd, strerror(errno));
243 } 243 }
244 if (S_ISCHR(buf.st_mode)) return kTerminal; 244 if (S_ISCHR(buf.st_mode)) return kTerminal;
245 if (S_ISFIFO(buf.st_mode)) return kPipe; 245 if (S_ISFIFO(buf.st_mode)) return kPipe;
246 if (S_ISSOCK(buf.st_mode)) return kSocket; 246 if (S_ISSOCK(buf.st_mode)) return kSocket;
247 if (S_ISREG(buf.st_mode)) return kFile; 247 if (S_ISREG(buf.st_mode)) return kFile;
248 return kOther; 248 return kOther;
249 } 249 }
OLDNEW
« no previous file with comments | « runtime/bin/file_linux.cc ('k') | runtime/bin/file_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698