I'm writing my own file indexer similar to Google Desktop. I'm in the baby stages right now and I'm trying to use as many FreeBSD commands where I can so I don't have to write the same thing again. Where I'm at right now is I've created a class called Crawler. I'm using
Here's the code I have so far
$ locate / * > database.tmp
to get a list of all the files that user can see on the HDD. After that is done I will then go through each file doing my indexing which I haven't started to write yet. My question is instead of using the locate command and dumping it into a file can I directly put it into a dynamic String array? I think this would be faster and easier.Here's the code I have so far
Code:
/*
* Crawler.h
*
* Created on: Jul 8, 2012
* Author: kclark
*/
#ifndef CRAWLER_H_
#define CRAWLER_H_
class Crawler {
public:
void startCrawl();
private:
void getFiles();
int getLines();
};
void Crawler::startCrawl()
{
getFiles();
int dbLines = getLines();
}
void Crawler::getFiles()
{
char record[1000]; // Declaration of record
sprintf(record,"/usr/bin/locate * / > database.tmp"); // Get the list of files
system(record); // Run the command
}
int Crawler::getLines()
{
char record[1000]; // Declaration of record
sprintf(record,"cat database.tmp | wc -l"); // Count the lines
return system(record); // Run the command
}
#endif /* CRAWLER_H_ */