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

Side by Side Diff: runtime/bin/file_linux.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
« no previous file with comments | « runtime/bin/file_impl.dart ('k') | runtime/bin/file_macos.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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 if (pathname != NULL) { 170 if (pathname != NULL) {
171 do { 171 do {
172 abs_path = realpath(pathname, NULL); 172 abs_path = realpath(pathname, NULL);
173 } while (abs_path == NULL && errno == EINTR); 173 } while (abs_path == NULL && errno == EINTR);
174 ASSERT(abs_path == NULL || IsAbsolutePath(abs_path)); 174 ASSERT(abs_path == NULL || IsAbsolutePath(abs_path));
175 } 175 }
176 return abs_path; 176 return abs_path;
177 } 177 }
178 178
179 179
180 char* File::GetContainingDirectory(char* pathname) {
181 ASSERT(Exists(pathname));
Søren Gjesse 2012/02/22 16:13:08 Isn't this ASSERT dangerous? Any file can disappea
Mads Ager (google) 2012/02/22 16:17:27 Good point. Removed on all platforms.
182 char* path = NULL;
183 do {
184 path = dirname(pathname);
185 } while (path == NULL && errno == EINTR);
186 return GetCanonicalPath(path);
187 }
188
189
180 const char* File::PathSeparator() { 190 const char* File::PathSeparator() {
181 return "/"; 191 return "/";
182 } 192 }
183 193
184 194
185 const char* File::StringEscapedPathSeparator() { 195 const char* File::StringEscapedPathSeparator() {
186 return "/"; 196 return "/";
187 } 197 }
188 198
189 199
190 File::StdioHandleType File::GetStdioHandleType(int fd) { 200 File::StdioHandleType File::GetStdioHandleType(int fd) {
191 ASSERT(0 <= fd && fd <= 2); 201 ASSERT(0 <= fd && fd <= 2);
192 struct stat buf; 202 struct stat buf;
193 int result = fstat(fd, &buf); 203 int result = fstat(fd, &buf);
194 if (result == -1) { 204 if (result == -1) {
195 FATAL2("Failed stat on file descriptor %d: %s", fd, strerror(errno)); 205 FATAL2("Failed stat on file descriptor %d: %s", fd, strerror(errno));
196 } 206 }
197 if (S_ISCHR(buf.st_mode)) return kTerminal; 207 if (S_ISCHR(buf.st_mode)) return kTerminal;
198 if (S_ISFIFO(buf.st_mode)) return kPipe; 208 if (S_ISFIFO(buf.st_mode)) return kPipe;
199 if (S_ISREG(buf.st_mode)) return kFile; 209 if (S_ISREG(buf.st_mode)) return kFile;
200 return kOther; 210 return kOther;
201 } 211 }
OLDNEW
« no previous file with comments | « runtime/bin/file_impl.dart ('k') | runtime/bin/file_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698