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

Comparing FeepingCreaturism/FeepingCreaturism.cpp (file contents):
Revision 251 by Douglas Thrift, 2004-09-12T19:24:00-07:00 vs.
Revision 265 by Douglas Thrift, 2004-10-27T01:50:34-07:00

# Line 8 | Line 8
8   #include "Matcher.hpp"
9   #include "Jargon.hpp"
10  
11 < extern "C"
12 < {
13 < #include <sys/types.h>
14 < #include <sys/stat.h>
15 < #include <fts.h>
16 < }
11 > #include <menes-api/exename.hpp>
12 > #include <menes-app/simple.hpp>
13  
14 < int main(int argc, char* argv[])
14 > int Main(const app::Options& options)
15   {
16 <        FeepingCreaturism::program = argv[0];
16 >        FeepingCreaturism::program = api::GetExecutablePath().GetName();
17  
18          FeepingCreaturism creaturism;
19  
# Line 62 | Line 58 | bool FeepingCreaturism::CaseLess::operat
58          std::transform(one.begin(), one.end(), one_.begin(), ::tolower);
59          std::transform(two.begin(), two.end(), two_.begin(), ::tolower);
60  
61 +        if (one_ == two_) return one < two;
62 +
63          return one_ < two_;
64   }
65  
66   void FeepingCreaturism::initialize()
67   {
68 <        ext::Handle<xml::Document> document(xml::Parse("jargon.xml"));
69 <        ext::Handle<xml::Node> node(*document/"feepingcreaturism");
68 >        _H<xml::Document> document(xml::Parse("jargon.xml"));
69 >        _H<xml::Node> node(*document/"feepingcreaturism");
70  
71          this->path = *node/"jargon";
72          this->matcher = *node/"matcher";
73  
74 <        char* path[] = { new char[this->path.GetData().GetSize()] };
74 >        _L<ext::String> args(1, this->path);
75  
76 <        std::strcpy(path[0], this->path.NullTerminate());
76 >        args.InsertLast("-type");
77 >        args.InsertLast("f");
78  
79 <        ::FTS* traversal(::fts_open(path, FTS_LOGICAL, NULL));
79 >        _S<api::Process> find("/usr/bin/find", args);
80          Matcher matcher("^" + this->path + "/(" + this->matcher + ")$");
81 +        ext::String path;
82  
83 <        if (traversal == NULL)
83 >        while (ios::ReadLine(*find.GetReader(), path)) if (matcher == path)
84          {
85 <                api::Cerr << program << ": Horrible Failure!\n";
86 <
87 <                std::exit(1);
85 >                jargon.insert(matcher[1]);
86          }
89
90        for (::FTSENT* entity(::fts_read(traversal)); entity != NULL;
91                entity = ::fts_read(traversal))
92        {
93                if (entity->fts_info == FTS_F && entity->fts_path == matcher)
94                {
95                        jargon.insert(matcher[1]);
96                }
97        }
98
99        ::fts_close(traversal);
100
101        delete [] path[0];
87   }
88  
89   void FeepingCreaturism::parse()

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines