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

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

Issue 13654002: Change how File/Directory/Link .delete works. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix windows error codes. 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_ANDROID) 6 #if defined(TARGET_OS_ANDROID)
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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } 159 }
160 160
161 161
162 bool File::CreateLink(const char* name, const char* target) { 162 bool File::CreateLink(const char* name, const char* target) {
163 int status = TEMP_FAILURE_RETRY(symlink(target, name)); 163 int status = TEMP_FAILURE_RETRY(symlink(target, name));
164 return (status == 0); 164 return (status == 0);
165 } 165 }
166 166
167 167
168 bool File::Delete(const char* name) { 168 bool File::Delete(const char* name) {
169 int status = TEMP_FAILURE_RETRY(remove(name)); 169 File::Type type = File::GetType(name, true);
170 if (status == -1) { 170 if (type == kIsFile) {
171 return false; 171 return TEMP_FAILURE_RETRY(unlink(name)) == 0;
172 } else if (type == kIsDirectory) {
173 errno = EISDIR;
174 } else {
175 errno = ENOENT;
172 } 176 }
173 return true; 177 return false;
174 } 178 }
175 179
176 180
181 bool File::DeleteLink(const char* name) {
182 File::Type type = File::GetType(name, false);
183 if (type == kIsLink) {
184 return TEMP_FAILURE_RETRY(unlink(name)) == 0;
185 }
186 errno = EINVAL;
187 return false;
188 }
189
190
177 off_t File::LengthFromPath(const char* name) { 191 off_t File::LengthFromPath(const char* name) {
178 struct stat st; 192 struct stat st;
179 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { 193 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) {
180 return st.st_size; 194 return st.st_size;
181 } 195 }
182 return -1; 196 return -1;
183 } 197 }
184 198
185 199
186 time_t File::LastModified(const char* name) { 200 time_t File::LastModified(const char* name) {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 TEMP_FAILURE_RETRY(lstat(file_2, &file_2_info)) == -1) { 309 TEMP_FAILURE_RETRY(lstat(file_2, &file_2_info)) == -1) {
296 return File::kError; 310 return File::kError;
297 } 311 }
298 return (file_1_info.st_ino == file_2_info.st_ino && 312 return (file_1_info.st_ino == file_2_info.st_ino &&
299 file_1_info.st_dev == file_2_info.st_dev) ? 313 file_1_info.st_dev == file_2_info.st_dev) ?
300 File::kIdentical : 314 File::kIdentical :
301 File::kDifferent; 315 File::kDifferent;
302 } 316 }
303 317
304 #endif // defined(TARGET_OS_ANDROID) 318 #endif // defined(TARGET_OS_ANDROID)
OLDNEW
« no previous file with comments | « runtime/bin/file.cc ('k') | runtime/bin/file_linux.cc » ('j') | runtime/bin/file_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698