46 |
|
// |
47 |
|
// Douglas Thrift |
48 |
|
// |
49 |
< |
// Indexer.cpp |
49 |
> |
// $Id: Indexer.cpp,v 1.12 2003/07/15 01:30:46 douglas Exp $ |
50 |
|
|
51 |
|
#include "Indexer.h" |
52 |
|
|
53 |
< |
Indexer::Indexer(string& indexFile, set<string>& domains, |
54 |
< |
set<string>& restrictions) |
53 |
> |
#ifndef _WIN32 |
54 |
> |
#include <unistd.h> |
55 |
> |
#else // _WIN32 |
56 |
> |
inline int unlink(const char* filename) { return DeleteFile(filename); } |
57 |
> |
#endif // _WIN32 |
58 |
> |
|
59 |
> |
Indexer::Indexer(string& indexFile, set<string>& domains, set<string>& |
60 |
> |
restrictions) |
61 |
|
{ |
62 |
|
this->indexFile = indexFile; |
63 |
|
this->domains = domains; |
95 |
|
|
96 |
|
fin.close(); |
97 |
|
|
98 |
< |
ofstream fout(indexFile.c_str()); |
98 |
> |
string lock = indexFile + ".lock"; |
99 |
> |
|
100 |
> |
ofstream fout(lock.c_str()); |
101 |
> |
fout.close(); |
102 |
> |
fout.open(indexFile.c_str()); |
103 |
|
|
104 |
|
fout << "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" standalone=\"no\"?>" |
105 |
|
<< "\n<!DOCTYPE index SYSTEM \"index.dtd\">\n" |
112 |
|
fout << "</index>\n"; |
113 |
|
|
114 |
|
fout.close(); |
115 |
+ |
|
116 |
+ |
unlink(lock.c_str()); |
117 |
|
} |
118 |
|
|
119 |
|
void Indexer::index(URL& url, ofstream& fout, const string referer) |