OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This command-line program dumps the contents of a set of cache files, either | 5 // This command-line program dumps the contents of a set of cache files, either |
6 // to stdout or to another set of cache files. | 6 // to stdout or to another set of cache files. |
7 | 7 |
8 #include <stdio.h> | 8 #include <stdio.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 enum Errors { | 26 enum Errors { |
27 GENERIC = -1, | 27 GENERIC = -1, |
28 ALL_GOOD = 0, | 28 ALL_GOOD = 0, |
29 INVALID_ARGUMENT = 1, | 29 INVALID_ARGUMENT = 1, |
30 FILE_ACCESS_ERROR, | 30 FILE_ACCESS_ERROR, |
31 UNKNOWN_VERSION, | 31 UNKNOWN_VERSION, |
32 TOOL_NOT_FOUND, | 32 TOOL_NOT_FOUND, |
33 }; | 33 }; |
34 | 34 |
| 35 #if defined(OS_WIN) |
35 const char kUpgradeHelp[] = | 36 const char kUpgradeHelp[] = |
36 "\nIn order to use the upgrade function, a version of this tool that\n" | 37 "\nIn order to use the upgrade function, a version of this tool that\n" |
37 "understands the file format of the files to upgrade is needed. For\n" | 38 "understands the file format of the files to upgrade is needed. For\n" |
38 "instance, to upgrade files saved with file format 3.4 to version 5.2,\n" | 39 "instance, to upgrade files saved with file format 3.4 to version 5.2,\n" |
39 "a version of this program that was compiled with version 3.4 has to be\n" | 40 "a version of this program that was compiled with version 3.4 has to be\n" |
40 "located beside this executable, and named dump_cache_3.exe, and this\n" | 41 "located beside this executable, and named dump_cache_3.exe, and this\n" |
41 "executable should be compiled with version 5.2 being the current one."; | 42 "executable should be compiled with version 5.2 being the current one."; |
| 43 #endif // defined(OS_WIN) |
42 | 44 |
43 // Folders to read and write cache files. | 45 // Folders to read and write cache files. |
44 const char kInputPath[] = "input"; | 46 const char kInputPath[] = "input"; |
45 const char kOutputPath[] = "output"; | 47 const char kOutputPath[] = "output"; |
46 | 48 |
47 // Dumps the file headers to stdout. | 49 // Dumps the file headers to stdout. |
48 const char kDumpHeaders[] = "dump-headers"; | 50 const char kDumpHeaders[] = "dump-headers"; |
49 | 51 |
50 // Dumps all entries to stdout. | 52 // Dumps all entries to stdout. |
51 const char kDumpContents[] = "dump-contents"; | 53 const char kDumpContents[] = "dump-contents"; |
52 | 54 |
53 // Convert the cache to files. | 55 // Convert the cache to files. |
54 const char kDumpToFiles[] = "dump-to-files"; | 56 const char kDumpToFiles[] = "dump-to-files"; |
55 | 57 |
56 // Upgrade an old version to the current one. | 58 // Upgrade an old version to the current one. |
57 const char kUpgrade[] = "upgrade"; | 59 const char kUpgrade[] = "upgrade"; |
58 | 60 |
59 // Internal use: | 61 // Internal use: |
60 const char kSlave[] = "slave"; | 62 const char kSlave[] = "slave"; |
| 63 #if defined(OS_WIN) |
61 const char kPipe[] = "pipe"; | 64 const char kPipe[] = "pipe"; |
| 65 #endif // defined(OS_WIN) |
62 | 66 |
63 int Help() { | 67 int Help() { |
64 printf("warning: input files are modified by this tool\n"); | 68 printf("warning: input files are modified by this tool\n"); |
65 printf("dump_cache --input=path1 [--output=path2]\n"); | 69 printf("dump_cache --input=path1 [--output=path2]\n"); |
66 printf("--dump-headers: display file headers\n"); | 70 printf("--dump-headers: display file headers\n"); |
67 printf("--dump-contents: display all entries\n"); | 71 printf("--dump-contents: display all entries\n"); |
68 printf("--upgrade: copy contents to the output path\n"); | 72 printf("--upgrade: copy contents to the output path\n"); |
69 printf("--dump-to-files: write the contents of the cache to files\n"); | 73 printf("--dump-to-files: write the contents of the cache to files\n"); |
70 return INVALID_ARGUMENT; | 74 return INVALID_ARGUMENT; |
71 } | 75 } |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 } | 178 } |
175 | 179 |
176 if (command_line.HasSwitch(kDumpContents)) | 180 if (command_line.HasSwitch(kDumpContents)) |
177 return DumpContents(input_path); | 181 return DumpContents(input_path); |
178 | 182 |
179 if (command_line.HasSwitch(kDumpHeaders)) | 183 if (command_line.HasSwitch(kDumpHeaders)) |
180 return DumpHeaders(input_path); | 184 return DumpHeaders(input_path); |
181 | 185 |
182 return Help(); | 186 return Help(); |
183 } | 187 } |
OLD | NEW |