// File System // // Douglas Thrift // // $Id$ #include #include #include "FileSystem.hpp" FileSystem::FileSystem(const cse::String &sitemap, const cse::String &base, ext::Queue &queue, api::ThreadMutex &queueLock, const _R &command) : CommandRunner(sitemap, queue, queueLock) { api::Cout << _B("File System") << ios::NewLine; Directory(command->root, _S() << base << command->path, true); } void FileSystem::Directory(const api::Path &directory, const cse::String &base, bool root) { ext::RedBlackSet excludes(GetProperties >(_B("GoogleTron:Exclude"), directory.GetPath())); if (root) excludes.Insert(sitemap); _foreach (const _L, entry, client.GetEntries(directory.GetPath())) if (!entry->GetName().StartsWith('.') && !excludes.Contains(entry->GetName()) && client.GetProperty(_B("svn:mime-type"), directory.GetChild(entry->GetName()).GetPath()).IsEmpty()) switch (entry->GetKind()) { case Subversion::file: File(directory.GetChild(entry->GetName()), base, *entry); break; case Subversion::dir: Directory(directory.GetChild(entry->GetName()), _S() << base << entry->GetName() << _B("/")); break; _nodefault } } void FileSystem::File(const api::Path &file, const cse::String &base, const Subversion::Entry &entry) { _S location(base); if (!api::Pcre::RegEx(_B("^index\\..+$"))(entry.GetName())) { cse::String actually(client.GetProperty(_B("GoogleTron:Actually"), file.GetPath())); if (actually.IsEmpty()) location << entry.GetName(); else location << actually; } Url url(location, entry.GetModified(), GetFrequency(client.GetProperty(_B("GoogleTron:Frequency"), file.GetPath())), GetPriority(client.GetProperty(_B("GoogleTron:Priority"), file.GetPath()))); _synchronized (queueLock) queue.Push(url); }