cleaned out idiotic commenting of FUNCDEF, which had been done when a strict compile
[feisty_meow.git] / nucleus / library / filesystem / directory_tree.cpp
index 2be520f3f5069f0b7a99ec6c4f619cf79309884e..68b82b7fc7d3cdbf41e27182acf178596f6a0d86 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <basis/functions.h>
 #include <basis/contracts.h>
+#include <loggers/program_wide_logger.h>
 #include <structures/object_packers.h>
 #include <structures/string_array.h>
 #include <textual/parser_bits.h>
 #include <stdio.h>
 
 using namespace basis;
-using namespace structures;
+using namespace loggers;
 using namespace nodes;
+using namespace structures;
 using namespace textual;
 
 #define DEBUG_DIRECTORY_TREE
   // uncomment for noisier version.
 
 #undef LOG
-#define LOG(to_print) printf("%s::%s: %s\n", static_class_name(), func, astring(to_print).s())
-//CLASS_EMERGENCY_LOG(program_wide_logger::get(), s)
+#define LOG(to_print) CLASS_EMERGENCY_LOG(program_wide_logger::get(), to_print)
+//printf("%s::%s: %s\n", static_class_name(), func, astring(to_print).s())
 
 //////////////
 
@@ -222,12 +224,18 @@ void directory_tree::traverse(const astring &path, const char *pattern,
 
 bool directory_tree::reset(const astring &path, const char *pattern)
 {
+  FUNCDEF("reset");
   _scanned_okay = false;
   WHACK(_real_tree);
+//  filename temp_path(path);
+//  temp_path.canonicalize();
   *_path = path;
+//temp_path.raw();
   *_pattern = pattern;
   _real_tree = new filename_tree;
 
+LOG(astring("dirtree::reset to path: ") + path);
+
   // check that the top-level is healthy.
   directory curr(path, "*");
   if (!curr.good()) return false;
@@ -434,6 +442,12 @@ filename_tree *directory_tree::seek(const astring &dir_name_in,
     for (posn = 0; posn < examining.length(); posn++) {
       check = examining[posn];
       filename current(check->_dirname);
+      if (!current.is_normal()) {
+//#ifdef DEBUG_DIRECTORY_TREE
+        LOG(astring("skipping abnormal dir: \"") + current + "\"");
+//#endif
+        continue;
+      }
 #ifdef DEBUG_DIRECTORY_TREE
       LOG(astring("looking at ") + current.raw());
 #endif
@@ -492,7 +506,7 @@ bool directory_tree::calculate(filename_tree *start, bool just_size)
   while (directory_tree::current_dir(*ted, curr)) {
     if (!curr.is_normal()) {
 //#ifdef DEBUG_DIRECTORY_TREE
-      LOG(astring("skipping abnormal dir:  ") + curr);
+      LOG(astring("skipping abnormal dir: \"") + curr + "\"");
 //#endif
       directory_tree::next(*ted);
       continue;  // scary non-simple file type.
@@ -510,7 +524,7 @@ bool directory_tree::calculate(filename_tree *start, bool just_size)
 #endif
       if (!curr_file.is_normal()) {
 //#ifdef DEBUG_DIRECTORY_TREE
-        LOG(astring("skipping abnormal file:  ") + curr);
+        LOG(astring("skipping abnormal file: \"") + curr + "\"");
 //#endif
         continue;
       }
@@ -609,6 +623,11 @@ bool directory_tree::compare_trees(const directory_tree &source,
     if (target_start.raw().t()) {
       corresponding_name = filename(target_start.raw()
           + filename::default_separator() + corresponding_name.raw());
+/*doesn't help, not right yet.    } else {
+      // if they didn't give us a place to start, we start at the top.
+      corresponding_name = filename(target.path()
+          + filename::default_separator() + corresponding_name.raw());
+*/
     }
 #ifdef DEBUG_DIRECTORY_TREE
     LOG(astring("target with start is: ") + corresponding_name);
@@ -805,8 +824,8 @@ outcome directory_tree::add_path(const astring &new_item, bool just_size)
   int file_subtract = 0;  // if it's a file, then we remove last component.
   if (!adding.is_directory()) file_subtract = 1;
 #ifdef DEBUG_DIRECTORY_TREE
-  if (file_subtract) LOG(astring("adding a file ") + new_item);
-  else LOG(astring("adding a directory ") + new_item);
+  if (file_subtract) { LOG(astring("adding a file ") + new_item); }
+  else { LOG(astring("adding a directory ") + new_item); }
 #endif
 
   // find the common root, break up the path into pieces, and tell us where