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

Unified Diff: tools/android/timemodified/timemodified.cc

Issue 17467003: [android] Switch test scripts to use last modified time instead of md5sum when checking dependencie… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed comments on timemodified.cc Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
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..f37a7af97ca68fbbddc207acf9e5ab56d3ab8cb7
--- /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.h"
+
+namespace {
+
+bool PrintFileAccessTime(const base::FilePath& path) {
+ base::PlatformFileInfo file_info;
+ if (!file_util::GetFileInfo(path, &file_info)) {
+ LOG(WARNING) << "Failed to get file info for: " << path.LossyDisplayName();
+ return false;
+ }
+ std::cout << file_info.last_modified.ToTimeT() << " "
+ << base::MakeAbsoluteFilePath(path).value() << std::endl;
+}
+
+// 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) {
+ const std::string svn_dir_component = FILE_PATH_LITERAL("/.svn/");
frankf 2013/07/02 18:45:29 have a ignore list with .git as well?
craigdh 2013/07/02 20:34:15 This isn't an issue at the moment. Added a TODO bu
+ for (const char** file = files; file != files + num_files; ++file) {
+ base::FilePath file_path(*file);
+ if (file_util::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);
+}

Powered by Google App Engine
This is Rietveld 408576698