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 261 by Douglas Thrift, 2004-10-07T22:20:16-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 }
17
11   #include <menes-api/exename.hpp>
12   #include <menes-app/simple.hpp>
13  
# Line 72 | Line 65 | bool FeepingCreaturism::CaseLess::operat
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";
91 <
92 <                std::exit(1);
85 >                jargon.insert(matcher[1]);
86          }
94
95        for (::FTSENT* entity(::fts_read(traversal)); entity != NULL;
96                entity = ::fts_read(traversal))
97        {
98                if (entity->fts_info == FTS_F && entity->fts_path == matcher)
99                {
100                        jargon.insert(matcher[1]);
101                }
102        }
103
104        ::fts_close(traversal);
105
106        delete [] path[0];
87   }
88  
89   void FeepingCreaturism::parse()

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines