ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/GoogleTron/GoogleTron.cpp
(Generate patch)

Comparing GoogleTron/GoogleTron.cpp (file contents):
Revision 681 by douglas, 2006-03-06T02:00:10-08:00 vs.
Revision 687 by douglas, 2006-03-06T18:05:20-08:00

# Line 20 | Line 20
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=(.*)$")), exclude(_B("^-exclude=(.+)$"));
26  
27          _foreach (const app::ArgumentList, arg, app::GetArguments())
28          {
29                  api::Pcre::RegEx::Match match;
30 +                _R<FileSystemCommand> fs;
31  
32                  if (match = sitemap_(*arg))
33                          sitemap = match[1];
34 +                else if (match = fs_(*arg))
35 +                        commands.InsertLast(new _H<FileSystemCommand>(match[1]));
36 +                else if (commands.GetSize() && (fs = dynamic_cast<FileSystemCommand *>(commands.Last().GetValue())) && (match = exclude(*arg)))
37 +                        fs->excludes.InsertLast(match[1]);
38                  else
39                  {
40 <                        api::Cout << _B("Usage: ") << api::GetExecutablePath().GetName() << _B(" [-sitemap=sitemap]") << ios::NewLine;
40 >                        api::Cout << _B("Usage: ") << api::GetExecutablePath().GetName() << _B(" [-sitemap=.+] [-fs=.* [-exclude=.+] ...] ...") << ios::NewLine;
41  
42                          return 1;
43                  }
44          }
45  
46 <        GoogleTron tron(sitemap);
46 >        GoogleTron tron(sitemap, commands);
47  
48          return 0;
49   }
50  
51 < GoogleTron::GoogleTron(const cse::String &sitemap) : working(true), sitemap(sitemap), output(hop::BindAll(&GoogleTron::Output, this))
51 > GoogleTron::GoogleTron(const cse::String &sitemap, const _L<_R<Command> > &commands) : working(true), sitemap(sitemap), output(hop::BindAll(&GoogleTron::Output, this))
52   {
53 <        // XXX: start some threads
53 >        _foreach (const _L<_R<Command> >, command_, commands)
54 >                if (_R<FileSystemCommand> command = dynamic_cast<FileSystemCommand *>(command_->GetValue()))
55 >                        threads.Add(hop::BindAll(&GoogleTron::FileSystem_, this, command));
56   }
57  
58   GoogleTron::~GoogleTron()
# Line 107 | Line 115 | int GoogleTron::Output()
115  
116          return 0;
117   }
118 +
119 + int GoogleTron::FileSystem_(const _R<FileSystemCommand> &command)
120 + {
121 +        FileSystem fs(sitemap, queue, queueLock, command);
122 +
123 +        return 0;
124 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines