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 243 by Douglas Thrift, 2004-09-11T21:27:10-07:00 vs.
Revision 270 by Douglas Thrift, 2004-10-27T23:44:48-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 }
17
11   #include <menes-api/exename.hpp>
12 < #include <menes-app/application.hpp>
12 > #include <menes-app/simple.hpp>
13  
14 < struct FeepingCreaturismCommand : public app::Application
14 > int Main(const app::Options& options)
15   {
16 <        virtual int Run(const app::ArgumentList& args)
24 <        {
25 <                FeepingCreaturism::program = api::GetExecutableName();
16 >        FeepingCreaturism::program = api::GetExecutablePath().GetName();
17  
18 <                FeepingCreaturism creaturism;
18 >        FeepingCreaturism creaturism;
19  
20 <                return 0;
21 <        }
31 < } creaturism;
20 >        return 0;
21 > }
22  
23   FeepingCreaturism::FeepingCreaturism()
24   {
# Line 68 | 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)
90 <        {
91 <                api::Cerr << program << ": Horrible Failure!\n";
92 <
93 <                std::exit(1);
94 <        }
95 <
96 <        for (::FTSENT* entity(::fts_read(traversal)); entity != NULL;
97 <                entity = ::fts_read(traversal))
83 >        while (ios::ReadLine(*find.GetReader(), path)) if (matcher == path)
84          {
85 <                if (entity->fts_info == FTS_F && entity->fts_path == matcher)
100 <                {
101 <                        jargon.insert(matcher[1]);
102 <                }
85 >                jargon.insert(matcher[1]);
86          }
87  
88 <        ::fts_close(traversal);
106 <
107 <        delete [] path[0];
88 >        find.Join();
89   }
90  
91   void FeepingCreaturism::parse()

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines