| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <io.h> | 8 #include <io.h> |
| 9 #endif | 9 #endif |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 } | 193 } |
| 194 | 194 |
| 195 bool IsDot(const FilePath& path) { | 195 bool IsDot(const FilePath& path) { |
| 196 return FILE_PATH_LITERAL(".") == path.BaseName().value(); | 196 return FILE_PATH_LITERAL(".") == path.BaseName().value(); |
| 197 } | 197 } |
| 198 | 198 |
| 199 bool IsDotDot(const FilePath& path) { | 199 bool IsDotDot(const FilePath& path) { |
| 200 return FILE_PATH_LITERAL("..") == path.BaseName().value(); | 200 return FILE_PATH_LITERAL("..") == path.BaseName().value(); |
| 201 } | 201 } |
| 202 | 202 |
| 203 bool TouchFile(const FilePath& path, | |
| 204 const base::Time& last_accessed, | |
| 205 const base::Time& last_modified) { | |
| 206 base::PlatformFile file = | |
| 207 base::CreatePlatformFile(path, | |
| 208 base::PLATFORM_FILE_OPEN | | |
| 209 base::PLATFORM_FILE_WRITE_ATTRIBUTES, | |
| 210 NULL, NULL); | |
| 211 if (file != base::kInvalidPlatformFileValue) { | |
| 212 bool result = base::TouchPlatformFile(file, last_accessed, last_modified); | |
| 213 base::ClosePlatformFile(file); | |
| 214 return result; | |
| 215 } | |
| 216 | |
| 217 return false; | |
| 218 } | |
| 219 | |
| 220 bool SetLastModifiedTime(const FilePath& path, | |
| 221 const base::Time& last_modified) { | |
| 222 return TouchFile(path, last_modified, last_modified); | |
| 223 } | |
| 224 | |
| 225 bool CloseFile(FILE* file) { | 203 bool CloseFile(FILE* file) { |
| 226 if (file == NULL) | 204 if (file == NULL) |
| 227 return true; | 205 return true; |
| 228 return fclose(file) == 0; | 206 return fclose(file) == 0; |
| 229 } | 207 } |
| 230 | 208 |
| 231 bool TruncateFile(FILE* file) { | 209 bool TruncateFile(FILE* file) { |
| 232 if (file == NULL) | 210 if (file == NULL) |
| 233 return false; | 211 return false; |
| 234 long current_offset = ftell(file); | 212 long current_offset = ftell(file); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 // FileEnumerator | 398 // FileEnumerator |
| 421 // | 399 // |
| 422 // Note: the main logic is in file_util_<platform>.cc | 400 // Note: the main logic is in file_util_<platform>.cc |
| 423 | 401 |
| 424 bool FileEnumerator::ShouldSkip(const FilePath& path) { | 402 bool FileEnumerator::ShouldSkip(const FilePath& path) { |
| 425 FilePath::StringType basename = path.BaseName().value(); | 403 FilePath::StringType basename = path.BaseName().value(); |
| 426 return IsDot(path) || (IsDotDot(path) && !(INCLUDE_DOT_DOT & file_type_)); | 404 return IsDot(path) || (IsDotDot(path) && !(INCLUDE_DOT_DOT & file_type_)); |
| 427 } | 405 } |
| 428 | 406 |
| 429 } // namespace | 407 } // namespace |
| OLD | NEW |