OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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 // A tool to dump HTML5 filesystem from CUI. | 5 // A tool to dump HTML5 filesystem from CUI. |
6 // | 6 // |
7 // Usage: | 7 // Usage: |
8 // | 8 // |
9 // ./out/Release/dump_file_system [options] <filesystem dir> [origin]... | 9 // ./out/Release/dump_file_system [options] <filesystem dir> [origin]... |
10 // | 10 // |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "storage/browser/fileapi/sandbox_directory_database.h" | 44 #include "storage/browser/fileapi/sandbox_directory_database.h" |
45 #include "storage/browser/fileapi/sandbox_file_system_backend.h" | 45 #include "storage/browser/fileapi/sandbox_file_system_backend.h" |
46 #include "storage/browser/fileapi/sandbox_origin_database.h" | 46 #include "storage/browser/fileapi/sandbox_origin_database.h" |
47 #include "storage/browser/fileapi/sandbox_prioritized_origin_database.h" | 47 #include "storage/browser/fileapi/sandbox_prioritized_origin_database.h" |
48 #include "storage/common/fileapi/file_system_types.h" | 48 #include "storage/common/fileapi/file_system_types.h" |
49 #include "storage/common/fileapi/file_system_util.h" | 49 #include "storage/common/fileapi/file_system_util.h" |
50 | 50 |
51 namespace { | 51 namespace { |
52 | 52 |
53 bool g_opt_long; | 53 bool g_opt_long; |
54 const char* g_opt_fs_type = "p"; | 54 const base::FilePath::CharType* g_opt_fs_type = FILE_PATH_LITERAL("p"); |
55 | 55 |
56 void ShowMessageAndExit(const std::string& msg) { | 56 void ShowMessageAndExit(const std::string& msg) { |
57 fprintf(stderr, "%s\n", msg.c_str()); | 57 fprintf(stderr, "%s\n", msg.c_str()); |
58 exit(EXIT_FAILURE); | 58 exit(EXIT_FAILURE); |
59 } | 59 } |
60 | 60 |
61 void ShowUsageAndExit(const std::string& arg0) { | 61 void ShowUsageAndExit(const std::string& arg0) { |
62 ShowMessageAndExit( | 62 ShowMessageAndExit( |
63 "Usage: " + arg0 + | 63 "Usage: " + arg0 + |
64 " [-l] [-t] [-s] <filesystem dir> [origin]..."); | 64 " [-l] [-t] [-s] <filesystem dir> [origin]..."); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 std::string username = "Default"; | 181 std::string username = "Default"; |
182 while (true) { | 182 while (true) { |
183 if (argc < 2) | 183 if (argc < 2) |
184 ShowUsageAndExit(arg0); | 184 ShowUsageAndExit(arg0); |
185 | 185 |
186 if (std::string(argv[1]) == "-l") { | 186 if (std::string(argv[1]) == "-l") { |
187 g_opt_long = true; | 187 g_opt_long = true; |
188 argc--; | 188 argc--; |
189 argv++; | 189 argv++; |
190 } else if (std::string(argv[1]) == "-t") { | 190 } else if (std::string(argv[1]) == "-t") { |
191 g_opt_fs_type = "t"; | 191 g_opt_fs_type = FILE_PATH_LITERAL("t"); |
192 argc--; | 192 argc--; |
193 argv++; | 193 argv++; |
194 } else if (std::string(argv[1]) == "-s") { | 194 } else if (std::string(argv[1]) == "-s") { |
195 g_opt_fs_type = "s"; | 195 g_opt_fs_type = FILE_PATH_LITERAL("s"); |
196 argc--; | 196 argc--; |
197 argv++; | 197 argv++; |
198 } else { | 198 } else { |
199 break; | 199 break; |
200 } | 200 } |
201 } | 201 } |
202 | 202 |
203 if (argc < 2) | 203 if (argc < 2) |
204 ShowUsageAndExit(arg0); | 204 ShowUsageAndExit(arg0); |
205 | 205 |
206 const base::FilePath file_system_dir = storage::StringToFilePath(argv[1]); | 206 const base::FilePath file_system_dir = storage::StringToFilePath(argv[1]); |
207 if (!base::DirectoryExists(file_system_dir)) { | 207 if (!base::DirectoryExists(file_system_dir)) { |
208 ShowMessageAndExit(storage::FilePathToString(file_system_dir) + | 208 ShowMessageAndExit(storage::FilePathToString(file_system_dir) + |
209 " is not a filesystem directory"); | 209 " is not a filesystem directory"); |
210 } | 210 } |
211 | 211 |
212 if (argc == 2) { | 212 if (argc == 2) { |
213 storage::DumpFileSystem(file_system_dir); | 213 storage::DumpFileSystem(file_system_dir); |
214 } else { | 214 } else { |
215 for (int i = 2; i < argc; i++) { | 215 for (int i = 2; i < argc; i++) { |
216 storage::DumpOrigin(file_system_dir, argv[i]); | 216 storage::DumpOrigin(file_system_dir, argv[i]); |
217 } | 217 } |
218 } | 218 } |
219 return 0; | 219 return 0; |
220 } | 220 } |
OLD | NEW |