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

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: 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
« no previous file with comments | « tools/android/android_tools.gyp ('k') | tools/android/timemodified/timemodified.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 return false;
24 std::cout << file_info.last_modified.ToTimeT() << " "
25 << base::MakeAbsoluteFilePath(path).value() << std::endl;
26 return true;
27 }
28
29 // Prints the access times of all files contained in |files|. This handles
30 // directories by walking them recursively. Excludes .svn directories and files
31 // under them.
32 bool PrintAccessTimesRecursively(int num_files, const char** files) {
33 // TODO(craigdh): Have an ignore list including .git directories.
34 const std::string svn_dir_component = FILE_PATH_LITERAL("/.svn/");
35 for (const char** file = files; file != files + num_files; ++file) {
36 base::FilePath file_path(*file);
37 if (base::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
« no previous file with comments | « tools/android/android_tools.gyp ('k') | tools/android/timemodified/timemodified.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698