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

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: 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..6fa55d8569d82a8d33a8ac319736bd08704db512
--- /dev/null
+++ b/tools/android/timemodified/timemodified.cc
@@ -0,0 +1,62 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
frankf 2013/06/20 22:52:38 13
craigdh 2013/07/02 17:26:12 Done.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Md5sum implementation for Android. This version handles files as well as
frankf 2013/06/20 22:52:38 Update doc
craigdh 2013/07/02 17:26:12 Done.
+// 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))
+ 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/");
+ 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);
+ for (base::FilePath child, empty;
+ (child = file_enumerator.Next()) != empty; ) {
frankf 2013/06/20 22:52:38 I think a while loop here is more readable.
craigdh 2013/07/02 17:26:12 Done.
+ // If the path contains /.svn/, ignore it.
+ if (child.value().find(svn_dir_component) == std::string::npos) {
+ if (!PrintFileAccessTime(child))
frankf 2013/06/20 22:52:38 Can we log the failure cases for debugging.
craigdh 2013/07/02 17:26:12 Done.
+ 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