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

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

Issue 12533008: dart:io | Add FileSystemEntity.typeSync to test for symbolic links. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 9 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_android.cc ('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 "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_LINUX) 6 #if defined(TARGET_OS_LINUX)
7 7
8 #include "bin/file.h" 8 #include "bin/file.h"
9 9
10 #include <errno.h> // NOLINT 10 #include <errno.h> // NOLINT
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 if (result == -1) { 239 if (result == -1) {
240 FATAL2("Failed stat on file descriptor %d: %s", fd, strerror(errno)); 240 FATAL2("Failed stat on file descriptor %d: %s", fd, strerror(errno));
241 } 241 }
242 if (S_ISCHR(buf.st_mode)) return kTerminal; 242 if (S_ISCHR(buf.st_mode)) return kTerminal;
243 if (S_ISFIFO(buf.st_mode)) return kPipe; 243 if (S_ISFIFO(buf.st_mode)) return kPipe;
244 if (S_ISSOCK(buf.st_mode)) return kSocket; 244 if (S_ISSOCK(buf.st_mode)) return kSocket;
245 if (S_ISREG(buf.st_mode)) return kFile; 245 if (S_ISREG(buf.st_mode)) return kFile;
246 return kOther; 246 return kOther;
247 } 247 }
248 248
249
250 File::Type File::GetType(const char* pathname, bool follow_links) {
251 struct stat entry_info;
252 int stat_success;
253 if (follow_links) {
254 stat_success = TEMP_FAILURE_RETRY(stat(pathname, &entry_info));
255 } else {
256 stat_success = TEMP_FAILURE_RETRY(lstat(pathname, &entry_info));
257 }
258 if (stat_success == -1) return File::kDoesNotExist;
259 if (S_ISDIR(entry_info.st_mode)) return File::kIsDirectory;
260 if (S_ISREG(entry_info.st_mode)) return File::kIsFile;
261 if (S_ISLNK(entry_info.st_mode)) return File::kIsLink;
262 return File::kDoesNotExist;
263 }
264
249 #endif // defined(TARGET_OS_LINUX) 265 #endif // defined(TARGET_OS_LINUX)
OLDNEW
« no previous file with comments | « runtime/bin/file_android.cc ('k') | runtime/bin/file_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698