X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=winsftp.c;h=a399f45e84ed2b172c4b890e8a2047f71f7dd8ba;hb=0edefb1809a783e8302ac2faf604e99729c6cda0;hp=a4dafd4aa9431129f83bab70c3dc484694e89f00;hpb=bfb9b2839323fd2af5fbfda5226fdda9ce40f7cb;p=PuTTY.git diff --git a/winsftp.c b/winsftp.c index a4dafd4a..a399f45e 100644 --- a/winsftp.c +++ b/winsftp.c @@ -2,15 +2,6 @@ * winsftp.c: the Windows-specific parts of PSFTP and PSCP. */ -#include -#ifndef AUTO_WINSOCK -#ifdef WINSOCK_TWO -#include -#else -#include -#endif -#endif - #include "putty.h" #include "psftp.h" @@ -303,6 +294,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 +304,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 +448,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. */ @@ -467,25 +471,6 @@ char *do_select(SOCKET skt, int startup) } extern int select_result(WPARAM, LPARAM); -/* - * Initialize the WinSock driver. - */ -static void init_winsock(void) -{ - WORD winsock_ver; - WSADATA wsadata; - - winsock_ver = MAKEWORD(1, 1); - if (WSAStartup(winsock_ver, &wsadata)) { - fprintf(stderr, "Unable to initialise WinSock"); - cleanup_exit(1); - } - if (LOBYTE(wsadata.wVersion) != 1 || HIBYTE(wsadata.wVersion) != 1) { - fprintf(stderr, "WinSock version is incompatible with 1.1"); - cleanup_exit(1); - } -} - /* * Wait for some network data and process it. */ @@ -498,7 +483,7 @@ int ssh_sftp_loop_iteration(void) FD_ZERO(&readfds); FD_SET(sftp_ssh_socket, &readfds); - if (select(1, &readfds, NULL, NULL, NULL) < 0) + if (p_select(1, &readfds, NULL, NULL, NULL) < 0) return -1; /* doom */ select_result((WPARAM) sftp_ssh_socket, (LPARAM) FD_READ); @@ -512,9 +497,7 @@ int main(int argc, char *argv[]) { int ret; - init_winsock(); ret = psftp_main(argc, argv); - WSACleanup(); return ret; }