got rid of all the absolute paths in the fitpc code

Previously, there were 2 places (BinaryLogReader and the HTTP file server) that
had "/home/driver/" hard coded. I changed both of those to use paths relative to
the location of the executable (retrieved from /proc/self/exe).

git-svn-id: https://robotics.mvla.net/svn/frc971/2013/trunk/src@4162 f308d9b7-e957-4cde-b6ac-9a88185e7312
diff --git a/aos/atom_code/core/BinaryLogReader.cpp b/aos/atom_code/core/BinaryLogReader.cpp
index 703a219..b673c26 100644
--- a/aos/atom_code/core/BinaryLogReader.cpp
+++ b/aos/atom_code/core/BinaryLogReader.cpp
@@ -13,25 +13,16 @@
 
 #include "aos/aos_core.h"
 #include "aos/atom_code/core/LogFileCommon.h"
+#include "aos/common/Configuration.h"
 
 static const char *const kCRIOName = "CRIO";
 
 int main() {
   aos::InitNRT();
 
-  char *folder_tmp;
-  if (asprintf(&folder_tmp, "%s/tmp/robot_logs", getpwuid(getuid())->pw_dir) == -1) {
-    LOG(ERROR, "couldn't figure out what folder to use because of %d (%s)\n",
-        errno, strerror(errno));
-    return EXIT_FAILURE;
-  }
-  std::string hack("/home/driver/tmp/robot_logs"); // TODO(brians) remove this hack
-  const char *folder = hack.c_str();
+  const char *folder = aos::configuration::GetLoggingDirectory();
   if (access(folder, R_OK | W_OK) == -1) {
-    fprintf(stderr,
-            "LogReader: error: folder '%s' does not exist. please create it\n",
-            folder);
-    return EXIT_FAILURE;
+    LOG(FATAL, "folder '%s' does not exist. please create it\n", folder);
   }
   LOG(INFO, "logging to folder '%s'\n", folder);
 
diff --git a/aos/atom_code/output/ctemplate_cache.cc b/aos/atom_code/output/ctemplate_cache.cc
new file mode 100644
index 0000000..a73e4ad
--- /dev/null
+++ b/aos/atom_code/output/ctemplate_cache.cc
@@ -0,0 +1,24 @@
+#include "aos/atom_code/output/ctemplate_cache.h"
+
+#include "aos/common/Configuration.h"
+#include "aos/common/once.h"
+
+namespace aos {
+namespace http {
+
+namespace {
+ctemplate::TemplateCache *CreateTemplateCache() {
+  ctemplate::TemplateCache *r = new ctemplate::TemplateCache();
+
+  r->SetTemplateRootDirectory(configuration::GetRootDirectory());
+
+  return r;
+}
+}  // namespace
+ctemplate::TemplateCache *get_template_cache() {
+  static Once<ctemplate::TemplateCache> once(CreateTemplateCache);
+  return once.Get();
+}
+
+}  // namespace http
+}  // namespace aos
diff --git a/aos/atom_code/output/ctemplate_cache.h b/aos/atom_code/output/ctemplate_cache.h
new file mode 100644
index 0000000..7e5dc3d
--- /dev/null
+++ b/aos/atom_code/output/ctemplate_cache.h
@@ -0,0 +1,12 @@
+#include "ctemplate/template_cache.h"
+
+namespace aos {
+namespace http {
+
+// Retrieves the cache used by all of the aos functions etc.
+// This cache will have its root directory set to the directory where the
+// executable is running from.
+ctemplate::TemplateCache *get_template_cache();
+
+}  // namespace http
+}  // namespace aos
diff --git a/aos/atom_code/output/output.gyp b/aos/atom_code/output/output.gyp
index 3e4abd4..d41fe7d 100644
--- a/aos/atom_code/output/output.gyp
+++ b/aos/atom_code/output/output.gyp
@@ -6,11 +6,13 @@
       'sources': [
         'HTTPServer.cpp',
         'evhttp_ctemplate_emitter.cc',
+        'ctemplate_cache.cc',
       ],
       'dependencies': [
         '<(AOS)/build/aos.gyp:libaos',
         '<(EXTERNALS):libevent',
         '<(EXTERNALS):ctemplate',
+        '<(AOS)/common/common.gyp:once',
       ],
       'export_dependent_settings': [
 # Our headers #include headers from both of these.