Chromium Code Reviews| Index: base/files/file_util.h |
| diff --git a/base/files/file_util.h b/base/files/file_util.h |
| index 77a87e7dade7df8db204dfd33aaafe7209c8a06b..5826664b9eda54a63cd5f6222718659f7cf273af 100644 |
| --- a/base/files/file_util.h |
| +++ b/base/files/file_util.h |
| @@ -55,21 +55,70 @@ BASE_EXPORT FilePath MakeAbsoluteFilePath(const FilePath& input); |
| // particularly speedy in any platform. |
| BASE_EXPORT int64_t ComputeDirectorySize(const FilePath& root_path); |
| -// Deletes the given path, whether it's a file or a directory. |
| -// If it's a directory, it's perfectly happy to delete all of the |
| -// directory's contents. Passing true to recursive deletes |
| -// subdirectories and their contents as well. |
| -// Returns true if successful, false otherwise. It is considered successful |
| -// to attempt to delete a file that does not exist. |
| +// Deletes the given path. If |path| names a directory and |recursive| is false, |
|
Nico
2017/01/10 18:31:55
should BUG= include 674135 too?
|
| +// the directory is only deleted if it is empty or is a symbolic link. If |path| |
| +// names a directory and |recursive| is true, this function will recursively |
| +// delete as much as possible within |path|, ideally ending in success when |
| +// |path| is deleted. In case of error, an unspecified amount of |path|'s |
| +// original contents may already have been deleted. |
| // |
| -// In posix environment and if |path| is a symbolic link, this deletes only |
| -// the symlink. (even if the symlink points to a non-existent file) |
| +// On Windows: as much as possible will always be deleted. Returns true if |
| +// |path| was deleted or did not exist. This function will not recurse into |
| +// symlinks or mount points (a.k.a. junction points), but rather will delete the |
| +// links/points themselves. |
| +// |
| +// In posix environment and if |path| is a symbolic link, this deletes only the |
| +// symlink. (even if the symlink points to a non-existent file) |
| // |
| // WARNING: USING THIS WITH recursive==true IS EQUIVALENT |
| // TO "rm -rf", SO USE WITH CAUTION. |
| BASE_EXPORT bool DeleteFile(const FilePath& path, bool recursive); |
| #if defined(OS_WIN) |
| +struct DeleteFileMetrics { |
| + enum TemporaryDirectoryLocation { |
| + UNDECIDED, // No attempt has yet been made to find a directory. |
| + NONE, // Failed to find a writeable temporary directory. |
| + TEMP, // Using %TEMP%. |
| + VOLUME_TEMP, // Using X:\Temp or X:\Tmp. |
| + PARENT, // Using the directory above the top-most item being deleted. |
| + ITEM, // Using the directory containing the item being deleted. |
| + }; |
| + |
| + TemporaryDirectoryLocation temporary_directory_location; |
| + |
| + // The number of items deleted via the DELETE_ON_CLOSE path. |
| + int delete_on_close_success_count; |
| + |
| + // The number of items in |delete_on_close_success_count| that were moved into |
| + // the temp directory. Ideally, this equals |delete_on_close_success_count|, |
| + // meaning that the operation was 100% successful. |
| + int move_to_temp_count; |
| + |
| + // The number of times opening an item to be deleted failed, resulting in a |
| + // fallback to plain ::DeleteFile that succeded. |
| + int delete_file_success_count; |
| + |
| + // The number of times each of the above strategies failed to delete an item. |
| + int fail_count; |
| + |
| + // The total number of retries before giving up (0 if success on the first |
| + // attempt). If the overall operation succeeds and this is not zero, the |
| + // retries were a very good thing. If the overall operation fails and the two |
| + // success counts above are non-zero, then perhaps more retries or some delays |
| + // would have helped. If the overall operation fails and the two success |
| + // counts above are zero, then it's likely that nothing would have helped. |
| + int total_retry_count; |
| + |
| + // The maximum recursion depth. |
| + int max_depth; |
| +}; |
| + |
| +// The same as DeleteFile, but with metrics about its performance. |
| +BASE_EXPORT bool DeleteFileWithMetrics(const FilePath& path, |
| + bool recursive, |
| + DeleteFileMetrics* metrics); |
| + |
| // Schedules to delete the given path, whether it's a file or a directory, until |
| // the operating system is restarted. |
| // Note: |