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

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

Issue 13654002: Change how File/Directory/Link .delete works. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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 "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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } 160 }
161 161
162 162
163 bool File::CreateLink(const char* name, const char* target) { 163 bool File::CreateLink(const char* name, const char* target) {
164 int status = TEMP_FAILURE_RETRY(symlink(target, name)); 164 int status = TEMP_FAILURE_RETRY(symlink(target, name));
165 return (status == 0); 165 return (status == 0);
166 } 166 }
167 167
168 168
169 bool File::Delete(const char* name) { 169 bool File::Delete(const char* name) {
170 int status = TEMP_FAILURE_RETRY(remove(name)); 170 if (File::GetType(name, false) == File::kIsLink) {
171 if (status == -1) { 171 if (File::GetType(name, true) == File::kIsFile) {
172 return TEMP_FAILURE_RETRY(unlink(name)) == 0;
173 }
Søren Gjesse 2013/04/05 12:52:50 Set errno before returning false.
Anders Johnsen 2013/04/08 06:50:49 Done.
172 return false; 174 return false;
173 } 175 }
174 return true; 176 return TEMP_FAILURE_RETRY(unlink(name)) == 0;
175 } 177 }
176 178
177 179
180 bool File::DeleteLink(const char* name) {
181 if (File::GetType(name, false) == kIsLink) {
182 return TEMP_FAILURE_RETRY(unlink(name)) == 0;
183 }
184 return false;
Søren Gjesse 2013/04/05 12:52:50 Set errno before returning false.
Anders Johnsen 2013/04/08 06:50:49 Done.
185 }
186
187
178 off_t File::LengthFromPath(const char* name) { 188 off_t File::LengthFromPath(const char* name) {
179 struct stat st; 189 struct stat st;
180 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { 190 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) {
181 return st.st_size; 191 return st.st_size;
182 } 192 }
183 return -1; 193 return -1;
184 } 194 }
185 195
186 196
187 time_t File::LastModified(const char* name) { 197 time_t File::LastModified(const char* name) {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 TEMP_FAILURE_RETRY(lstat(file_2, &file_2_info)) == -1) { 306 TEMP_FAILURE_RETRY(lstat(file_2, &file_2_info)) == -1) {
297 return File::kError; 307 return File::kError;
298 } 308 }
299 return (file_1_info.st_ino == file_2_info.st_ino && 309 return (file_1_info.st_ino == file_2_info.st_ino &&
300 file_1_info.st_dev == file_2_info.st_dev) ? 310 file_1_info.st_dev == file_2_info.st_dev) ?
301 File::kIdentical : 311 File::kIdentical :
302 File::kDifferent; 312 File::kDifferent;
303 } 313 }
304 314
305 #endif // defined(TARGET_OS_LINUX) 315 #endif // defined(TARGET_OS_LINUX)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698