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

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

Issue 12691002: dart:io | Add Link class, as sibling to File and Directory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix Windows errors 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 153
154 bool File::Create(const char* name) { 154 bool File::Create(const char* name) {
155 int fd = TEMP_FAILURE_RETRY(open(name, O_RDONLY | O_CREAT | O_CLOEXEC, 0666)); 155 int fd = TEMP_FAILURE_RETRY(open(name, O_RDONLY | O_CREAT | O_CLOEXEC, 0666));
156 if (fd < 0) { 156 if (fd < 0) {
157 return false; 157 return false;
158 } 158 }
159 return (close(fd) == 0); 159 return (close(fd) == 0);
160 } 160 }
161 161
162 162
163 bool File::CreateLink(const char* name, const char* target) {
164 int status = TEMP_FAILURE_RETRY(symlink(target, name));
165 return (status == 0);
166 }
167
168
163 bool File::Delete(const char* name) { 169 bool File::Delete(const char* name) {
164 int status = TEMP_FAILURE_RETRY(remove(name)); 170 int status = TEMP_FAILURE_RETRY(remove(name));
165 if (status == -1) { 171 if (status == -1) {
166 return false; 172 return false;
167 } 173 }
168 return true; 174 return true;
169 } 175 }
170 176
171 177
172 off_t File::LengthFromPath(const char* name) { 178 off_t File::LengthFromPath(const char* name) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 stat_success = TEMP_FAILURE_RETRY(lstat(pathname, &entry_info)); 263 stat_success = TEMP_FAILURE_RETRY(lstat(pathname, &entry_info));
258 } 264 }
259 if (stat_success == -1) return File::kDoesNotExist; 265 if (stat_success == -1) return File::kDoesNotExist;
260 if (S_ISDIR(entry_info.st_mode)) return File::kIsDirectory; 266 if (S_ISDIR(entry_info.st_mode)) return File::kIsDirectory;
261 if (S_ISREG(entry_info.st_mode)) return File::kIsFile; 267 if (S_ISREG(entry_info.st_mode)) return File::kIsFile;
262 if (S_ISLNK(entry_info.st_mode)) return File::kIsLink; 268 if (S_ISLNK(entry_info.st_mode)) return File::kIsLink;
263 return File::kDoesNotExist; 269 return File::kDoesNotExist;
264 } 270 }
265 271
266 #endif // defined(TARGET_OS_LINUX) 272 #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