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

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

Issue 9416096: Implement File.directory() and File.directorySync() to get (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Implement async version using isolate Created 8 years, 10 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
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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 ASSERT(resolved_path != NULL); 177 ASSERT(resolved_path != NULL);
178 do { 178 do {
179 abs_path = realpath(pathname, NULL); 179 abs_path = realpath(pathname, NULL);
180 } while (abs_path == NULL && errno == EINTR); 180 } while (abs_path == NULL && errno == EINTR);
181 ASSERT(abs_path == NULL || IsAbsolutePath(abs_path)); 181 ASSERT(abs_path == NULL || IsAbsolutePath(abs_path));
182 } 182 }
183 return abs_path; 183 return abs_path;
184 } 184 }
185 185
186 186
187 char* File::GetContainingDirectory(char* pathname) {
188 ASSERT(Exists(pathname));
189 char* path = NULL;
190 do {
191 path = dirname(pathname);
192 } while (path == NULL && errno == EINTR);
193 return GetCanonicalPath(path);
194 }
195
196
187 const char* File::PathSeparator() { 197 const char* File::PathSeparator() {
188 return "/"; 198 return "/";
189 } 199 }
190 200
191 201
192 const char* File::StringEscapedPathSeparator() { 202 const char* File::StringEscapedPathSeparator() {
193 return "/"; 203 return "/";
194 } 204 }
195 205
196 206
197 File::StdioHandleType File::GetStdioHandleType(int fd) { 207 File::StdioHandleType File::GetStdioHandleType(int fd) {
198 ASSERT(0 <= fd && fd <= 2); 208 ASSERT(0 <= fd && fd <= 2);
199 struct stat buf; 209 struct stat buf;
200 int result = fstat(fd, &buf); 210 int result = fstat(fd, &buf);
201 if (result == -1) { 211 if (result == -1) {
202 FATAL2("Failed stat on file descriptor %d: %s", fd, strerror(errno)); 212 FATAL2("Failed stat on file descriptor %d: %s", fd, strerror(errno));
203 } 213 }
204 if (S_ISCHR(buf.st_mode)) return kTerminal; 214 if (S_ISCHR(buf.st_mode)) return kTerminal;
205 if (S_ISFIFO(buf.st_mode)) return kPipe; 215 if (S_ISFIFO(buf.st_mode)) return kPipe;
206 if (S_ISREG(buf.st_mode)) return kFile; 216 if (S_ISREG(buf.st_mode)) return kFile;
207 return kOther; 217 return kOther;
208 } 218 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698