| Index: tools/android/timemodified/timemodified.cc
|
| diff --git a/tools/android/timemodified/timemodified.cc b/tools/android/timemodified/timemodified.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..ae1ee8acb9ba69a795c3f794845f40c06e96d088
|
| --- /dev/null
|
| +++ b/tools/android/timemodified/timemodified.cc
|
| @@ -0,0 +1,64 @@
|
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +// Recursively prints file modified times for Android. This version handles
|
| +// files as well as directories. Its output is sorted by file path.
|
| +
|
| +#include <iostream>
|
| +#include <string>
|
| +
|
| +#include "base/file_util.h"
|
| +#include "base/files/file_enumerator.h"
|
| +#include "base/files/file_path.h"
|
| +#include "base/logging.h"
|
| +#include "base/platform_file.h"
|
| +#include "base/time/time.h"
|
| +
|
| +namespace {
|
| +
|
| +bool PrintFileAccessTime(const base::FilePath& path) {
|
| + base::PlatformFileInfo file_info;
|
| + if (!file_util::GetFileInfo(path, &file_info))
|
| + return false;
|
| + std::cout << file_info.last_modified.ToTimeT() << " "
|
| + << base::MakeAbsoluteFilePath(path).value() << std::endl;
|
| + return true;
|
| +}
|
| +
|
| +// Prints the access times of all files contained in |files|. This handles
|
| +// directories by walking them recursively. Excludes .svn directories and files
|
| +// under them.
|
| +bool PrintAccessTimesRecursively(int num_files, const char** files) {
|
| + // TODO(craigdh): Have an ignore list including .git directories.
|
| + const std::string svn_dir_component = FILE_PATH_LITERAL("/.svn/");
|
| + for (const char** file = files; file != files + num_files; ++file) {
|
| + base::FilePath file_path(*file);
|
| + if (base::DirectoryExists(file_path)) {
|
| + base::FileEnumerator file_enumerator(
|
| + file_path, true /* recurse */, base::FileEnumerator::FILES);
|
| + base::FilePath child, empty;
|
| + while ((child = file_enumerator.Next()) != empty) {
|
| + // If the path contains /.svn/, ignore it.
|
| + if (child.value().find(svn_dir_component) == std::string::npos) {
|
| + if (!PrintFileAccessTime(child))
|
| + return false;
|
| + }
|
| + }
|
| + } else {
|
| + if (!PrintFileAccessTime(file_path))
|
| + return false;
|
| + }
|
| + }
|
| + return true;
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +int main(int argc, const char* argv[]) {
|
| + if (argc < 2) {
|
| + LOG(ERROR) << "Usage: timemodified <path/to/file_or_dir> ...";
|
| + return 1;
|
| + }
|
| + return PrintAccessTimesRecursively(argc - 1, argv + 1);
|
| +}
|
|
|