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

Side by Side 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, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Recursively prints file modified times for Android. This version handles
6 // files as well as directories. Its output is sorted by file path.
7
8 #include <iostream>
9 #include <string>
10
11 #include "base/file_util.h"
12 #include "base/files/file_enumerator.h"
13 #include "base/files/file_path.h"
14 #include "base/logging.h"
15 #include "base/platform_file.h"
16 #include "base/time.h"
17
18 namespace {
19
20 bool PrintFileAccessTime(const base::FilePath& path) {
21 base::PlatformFileInfo file_info;
22 if (!file_util::GetFileInfo(path, &file_info)) {
23 LOG(WARNING) << "Failed to get file info for: " << path.LossyDisplayName();
24 return false;
25 }
26 std::cout << file_info.last_modified.ToTimeT() << " "
27 << base::MakeAbsoluteFilePath(path).value() << std::endl;
28 }
29
30 // Prints the access times of all files contained in |files|. This handles
31 // directories by walking them recursively. Excludes .svn directories and files
32 // under them.
33 bool PrintAccessTimesRecursively(int num_files, const char** files) {
34 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
35 for (const char** file = files; file != files + num_files; ++file) {
36 base::FilePath file_path(*file);
37 if (file_util::DirectoryExists(file_path)) {
38 base::FileEnumerator file_enumerator(
39 file_path, true /* recurse */, base::FileEnumerator::FILES);
40 base::FilePath child, empty;
41 while ((child = file_enumerator.Next()) != empty) {
42 // If the path contains /.svn/, ignore it.
43 if (child.value().find(svn_dir_component) == std::string::npos) {
44 if (!PrintFileAccessTime(child))
45 return false;
46 }
47 }
48 } else {
49 if (!PrintFileAccessTime(file_path))
50 return false;
51 }
52 }
53 return true;
54 }
55
56 } // namespace
57
58 int main(int argc, const char* argv[]) {
59 if (argc < 2) {
60 LOG(ERROR) << "Usage: timemodified <path/to/file_or_dir> ...";
61 return 1;
62 }
63 return PrintAccessTimesRecursively(argc - 1, argv + 1);
64 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698