+ if (d_type == DT_UNKNOWN) {
+ struct stat s;
+ char path[PATH_MAX];
+ snprintf(path, PATH_MAX, "%s/%s",
+ ChrPtr(DirName), filedir_entry->d_name);
+ if (stat(path, &s) == 0) {
+ d_type = IFTODT(s.st_mode);
+ }
+ }
+ switch (d_type)
+ {
+ case DT_DIR:
+ /* Skip directories we are not interested in... */
+ if (strcmp(filedir_entry->d_name, ".svn") == 0)
+ continue;
+
+ FlushStrBuf(SubKey);
+ if (!Toplevel) {
+ /* If we're not toplevel, the upper dirs count as foo_bar_<local name>*/
+ StrBufAppendBuf(SubKey, BaseKey, 0);
+ StrBufAppendBufPlain(SubKey, HKEY("_"), 0);
+ }
+ StrBufAppendBufPlain(SubKey, filedir_entry->d_name, d_namelen, 0);
+
+ FlushStrBuf(SubDirectory);
+ StrBufAppendBuf(SubDirectory, DirName, 0);
+ if (ChrPtr(SubDirectory)[StrLength(SubDirectory) - 1] != '/')
+ StrBufAppendBufPlain(SubDirectory, HKEY("/"), 0);
+ StrBufAppendBufPlain(SubDirectory, filedir_entry->d_name, d_namelen, 0);
+
+ LoadTemplateDir(SubDirectory, big, SubKey);
+
+ break;
+ case DT_LNK: /* TODO: check whether its a file or a directory */
+ case DT_REG:
+
+
+ while ((d_without_ext > 0) && (filedir_entry->d_name[d_without_ext] != '.'))
+ d_without_ext --;
+ if ((d_without_ext == 0) || (d_namelen < 3))
+ continue;
+ if (((d_namelen > 1) && filedir_entry->d_name[d_namelen - 1] == '~') ||
+ (strcmp(&filedir_entry->d_name[d_without_ext], ".orig") == 0) ||
+ (strcmp(&filedir_entry->d_name[d_without_ext], ".swp") == 0))
+ continue; /* Ignore backup files... */
+ StrBufPrintf(FileName, "%s/%s", ChrPtr(DirName), filedir_entry->d_name);
+ MinorPtr = strchr(filedir_entry->d_name, '.');
+ if (MinorPtr != NULL)
+ *MinorPtr = '\0';
+ FlushStrBuf(Key);
+ if (!Toplevel) {
+ /* If we're not toplevel, the upper dirs count as foo_bar_<local name>*/
+ StrBufAppendBuf(Key, BaseKey, 0);
+ StrBufAppendBufPlain(Key, HKEY("_"), 0);
+ }
+ StrBufAppendBufPlain(Key, filedir_entry->d_name, MinorPtr - filedir_entry->d_name, 0);
+
+ if (LoadTemplates >= 1)
+ syslog(1, "%s %s\n", ChrPtr(FileName), ChrPtr(Key));
+ prepare_template(FileName, Key, big);
+ default:
+ break;
+ }