if (!strcmp(filename_transcoded.s(), par_dir.s())) continue;
#ifdef UNICODE
-//temp
+/*temp
to_unicode_persist(fudgemart, filename_transcoded);
if (memcmp((wchar_t*)fudgemart, wfd.cFileName, wcslen(wfd.cFileName)*2))
printf("failed to compare the string before and after transcoding\n");
+*/
#endif
//wprintf(to_unicode_temp("file is %ls\n"), (wchar_t*)to_unicode_temp(filename_transcoded));
filename temp_name(*_path, filename_transcoded.s());
+ if (!temp_name.is_normal()) {
+ LOG(astring("skipping abnormal file: ") + temp_name);
+ continue; // cannot be adding goofy named pipes etc; cannot manage those.
+ }
// add this to the appropriate list.
if (temp_name.is_directory()) {
using namespace nodes;
using namespace textual;
-//#define DEBUG_DIRECTORY_TREE
+#define DEBUG_DIRECTORY_TREE
// uncomment for noisier version.
#undef LOG
#ifdef DEBUG_DIRECTORY_TREE
LOG(astring("seeking path: ") + new_path);
#endif
+ if (!filename(new_path).is_normal()) {
+LOG(astring("bailing on weird dir: ") + new_path);
+ continue; // only regular directories please.
+ }
for (int q = 0; q < add_to.branches(); q++) {
filename_tree *curr_kid = (filename_tree *)add_to.branch(q);
#ifdef DEBUG_DIRECTORY_TREE
if (!target_now // there was no node, so we're adding everything...
|| !target_now->_files.member_with_state(*files[i], how_compare) ) {
// ... or we need to add this file since it's missing.
-
+/*
+//hmmm: this one might be redundant. we shouldn't add it in the first place.
+ if (!files[i]->is_normal()) {
+ LOG(astring("skipping abnormal file: ") + *files[i]);
+ continue; // wasn't useful to do this one.
+ }
+*/
#ifdef DEBUG_DIRECTORY_TREE
LOG(astring("adding record: ") + files[i]->text_form());
#endif
filename adding(new_item);
if (!adding.good()) {
LOG(astring("non-existent new item! ") + new_item);
+ return common::NOT_FOUND; // not an existing path.
+ }
+ if (!adding.is_normal()) {
+ LOG(astring("abnormal new item: ") + new_item);
return common::BAD_INPUT; // not a good path.
}
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)
+ if (file_subtract) LOG(astring("adding a file ") + new_item);
else LOG(astring("adding a directory ") + new_item);
#endif
return !!(fill.st_mode & S_IEXEC);
}
+bool filename::is_normal() const
+{
+ status_info fill;
+ if (!get_info(&fill))
+ return false;
+ bool weird = S_ISCHR(fill.st_mode)
+ || S_ISBLK(fill.st_mode)
+ || S_ISFIFO(fill.st_mode)
+ || S_ISSOCK(fill.st_mode);
+ return !weird;
+}
+
int filename::find_last_separator(const astring &look_at) const
{
int last_sep = -1;
bool is_readable() const;
bool is_executable() const;
+ // is_normal makes sure that the file or directory is not a named pipe or other
+ // special type of file. symbolic links are considered normal.
+ bool is_normal() const;
+
enum write_modes {
ALLOW_NEITHER = 0x0,
ALLOW_READ = 0x1, ALLOW_WRITE = 0x2,