1 |
douglas |
688 |
// File System |
2 |
|
|
// |
3 |
douglas |
686 |
// Douglas Thrift |
4 |
|
|
// |
5 |
|
|
// $Id$ |
6 |
|
|
|
7 |
|
|
#include <cxx/standard.hh> |
8 |
|
|
|
9 |
douglas |
705 |
#include <api/pcre/regex.hpp> |
10 |
|
|
|
11 |
douglas |
686 |
#include "FileSystem.hpp" |
12 |
|
|
|
13 |
douglas |
695 |
FileSystem::FileSystem(const cse::String &sitemap, const cse::String &base, ext::Queue<Url> &queue, api::ThreadMutex &queueLock, const _R<FileSystemCommand> &command) : CommandRunner(sitemap, base, queue, queueLock) |
14 |
douglas |
686 |
{ |
15 |
douglas |
688 |
api::Cout << _B("File System") << ios::NewLine; |
16 |
douglas |
698 |
|
17 |
douglas |
705 |
Directory(*command, base); |
18 |
douglas |
686 |
} |
19 |
douglas |
705 |
|
20 |
|
|
void FileSystem::Directory(const api::Path &directory, const cse::String &base) |
21 |
|
|
{ |
22 |
|
|
ext::RedBlackSet<cse::String> excludes; |
23 |
|
|
|
24 |
|
|
{ |
25 |
|
|
_S<ios::Buffer> property(client.GetProperty(_B("GoogleTron:Exclude"), directory.GetPath())); |
26 |
|
|
ext::Buffer exclude; |
27 |
|
|
|
28 |
|
|
while (ios::ReadLine(property, exclude)) |
29 |
|
|
excludes.Insert(exclude); |
30 |
|
|
} |
31 |
|
|
|
32 |
|
|
if (base == this->base) |
33 |
|
|
excludes.Insert(sitemap); |
34 |
|
|
|
35 |
|
|
_foreach (const _L<Subversion::Entry>, entry, client.GetEntries(directory.GetPath())) |
36 |
|
|
if (!entry->GetName().StartsWith('.') && !excludes.Contains(entry->GetName()) && client.GetProperty(_B("svn:mime-type"), directory.GetChild(entry->GetName()).GetPath()).IsEmpty()) |
37 |
|
|
switch (entry->GetKind()) |
38 |
|
|
{ |
39 |
|
|
case Subversion::file: |
40 |
|
|
File(directory.GetChild(entry->GetName()), base, *entry); |
41 |
|
|
break; |
42 |
|
|
case Subversion::dir: |
43 |
|
|
Directory(directory.GetChild(entry->GetName()), _S<ios::String>() << base << entry->GetName() << _B("/")); |
44 |
|
|
break; |
45 |
|
|
_nodefault |
46 |
|
|
} |
47 |
|
|
} |
48 |
|
|
|
49 |
|
|
void FileSystem::File(const api::Path &file, const cse::String &base, const Subversion::Entry &entry) |
50 |
|
|
{ |
51 |
|
|
_S<ios::String> location(base); |
52 |
|
|
|
53 |
|
|
if (!api::Pcre::RegEx(_B("^index\\..+$"))(entry.GetName())) |
54 |
|
|
{ |
55 |
|
|
cse::String actually(client.GetProperty(_B("GoogleTron:Actually"), file.GetPath())); |
56 |
|
|
|
57 |
|
|
if (actually.IsEmpty()) |
58 |
|
|
location << entry.GetName(); |
59 |
|
|
else |
60 |
|
|
location << actually; |
61 |
|
|
} |
62 |
|
|
|
63 |
|
|
Url url(location, entry.GetModified(), GetFrequency(client.GetProperty(_B("GoogleTron:Frequency"), file.GetPath())), GetPriority(client.GetProperty(_B("GoogleTron:Priority"), file.GetPath()))); |
64 |
|
|
|
65 |
|
|
_synchronized (queueLock) |
66 |
|
|
queue.Push(url); |
67 |
|
|
} |