... and there's a Unix port of PSCP. Ooh.
[u/mdw/putty] / winsftp.c
index a4dafd4..6687210 100644 (file)
--- a/winsftp.c
+++ b/winsftp.c
@@ -303,6 +303,7 @@ DirHandle *open_directory(char *name)
     h = FindFirstFile(findfile, &fdat);
     if (h == INVALID_HANDLE_VALUE)
        return NULL;
+    sfree(findfile);
 
     ret = snew(DirHandle);
     ret->h = h;
@@ -312,11 +313,18 @@ DirHandle *open_directory(char *name)
 
 char *read_filename(DirHandle *dir)
 {
-    if (!dir->name) {
+    while (!dir->name) {
        WIN32_FIND_DATA fdat;
        int ok = FindNextFile(dir->h, &fdat);
 
-       if (ok)
+       if (!ok)
+           return NULL;
+
+       if (fdat.cFileName[0] == '.' &&
+           (fdat.cFileName[1] == '\0' ||
+            (fdat.cFileName[1] == '.' && fdat.cFileName[2] == '\0')))
+           dir->name = NULL;
+       else
            dir->name = dupstr(fdat.cFileName);
     }
 
@@ -449,6 +457,11 @@ int create_directory(char *name)
     return CreateDirectory(name, NULL) != 0;
 }
 
+char *dir_file_cat(char *dir, char *file)
+{
+    return dupcat(dir, "\\", file, NULL);
+}
+
 /* ----------------------------------------------------------------------
  * Platform-specific network handling.
  */