-#else
- write(f->local_file, buf, strlen(buf));
- write(f->local_file, "\r\n", 2);
+ }
+
+ /*
+ * If recursion is on, dive into any subdirectories now -- note
+ * that each entry is stat()'ed twice, hopefully the OS will manage,
+ * and we've got our own dcache anyways -- this could be fixed at
+ * the expense of some memory, consider for later inclusion.
+ */
+ if (lo->recursive) {
+ for (i = 0; i < pglob.gl_pathc; i++) {
+ struct stat buf;
+ const char * const temp = pglob.gl_pathv[i];
+
+ /* don't dive into `.' or `..' */
+ if (lstat(temp, &buf) != -1 && S_ISDIR(buf.st_mode) &&
+ (temp[0] != '.' || (temp[1] != '.' && temp[1] != '\0'))) {
+ char tmp2[1024];
+
+ mwrite("\r\n", 2);
+
+ /* attach the pathname to the end of the displayed path */
+ if (disp_pathname[0] == '\0') {
+ snprintf(tmp2, 1024, "%s", temp);
+ } else {
+ snprintf(tmp2, 1024, "%s/%s", disp_pathname, temp);
+ }
+
+ chdir(temp);
+ pos = list_core(c, "*", tmp2, lo,
+#if HAVE_MMAP
+ size, pos);