20 |
|
int Main(const app::Options &options) |
21 |
|
{ |
22 |
|
cse::String sitemap(_B("sitemap.gz")); |
23 |
+ |
_L<_R<Command> > commands; |
24 |
|
|
25 |
< |
api::Pcre::RegEx sitemap_(_B("^-sitemap=(.+)$")); |
25 |
> |
api::Pcre::RegEx sitemap_(_B("^-sitemap=(.+)$")), fs(_B("^-fs=(.*)$")); |
26 |
|
|
27 |
|
_foreach (const app::ArgumentList, arg, app::GetArguments()) |
28 |
|
{ |
30 |
|
|
31 |
|
if (match = sitemap_(*arg)) |
32 |
|
sitemap = match[1]; |
33 |
+ |
else if (match = fs(*arg)) |
34 |
+ |
commands.InsertLast(new _H<FileSystemCommand>(match[1])); |
35 |
|
else |
36 |
|
{ |
37 |
< |
api::Cout << _B("Usage: ") << api::GetExecutablePath().GetName() << _B(" [-sitemap=sitemap]") << ios::NewLine; |
37 |
> |
api::Cout << _B("Usage: ") << api::GetExecutablePath().GetName() << _B(" [-sitemap=.+] [-fs=.*]") << ios::NewLine; |
38 |
|
|
39 |
|
return 1; |
40 |
|
} |
41 |
|
} |
42 |
|
|
43 |
< |
GoogleTron tron(sitemap); |
43 |
> |
GoogleTron tron(sitemap, commands); |
44 |
|
|
45 |
|
return 0; |
46 |
|
} |
47 |
|
|
48 |
< |
GoogleTron::GoogleTron(const cse::String &sitemap) : working(true), sitemap(sitemap), output(hop::BindAll(&GoogleTron::Output, this)) |
48 |
> |
GoogleTron::GoogleTron(const cse::String &sitemap, const _L<_R<Command> > &commands) : working(true), sitemap(sitemap), output(hop::BindAll(&GoogleTron::Output, this)) |
49 |
|
{ |
50 |
< |
// XXX: start some threads |
50 |
> |
_foreach (const _L<_R<Command> >, command_, commands) |
51 |
> |
if (_R<FileSystemCommand> command = dynamic_cast<FileSystemCommand *>(command_->GetValue())) |
52 |
> |
threads.Add(hop::BindAll(&GoogleTron::FileSystem_, this, command)); |
53 |
|
} |
54 |
|
|
55 |
|
GoogleTron::~GoogleTron() |
112 |
|
|
113 |
|
return 0; |
114 |
|
} |
115 |
+ |
|
116 |
+ |
int GoogleTron::FileSystem_(const _R<FileSystemCommand> &command) |
117 |
+ |
{ |
118 |
+ |
FileSystem fs(sitemap, queue, queueLock, command); |
119 |
+ |
|
120 |
+ |
return 0; |
121 |
+ |
} |