-
- if (argc == 2) {
- /* Find out if the source filespec covers multiple files
- if so, we should set the targetshouldbedirectory flag */
- HANDLE fh;
- WIN32_FIND_DATA fdat;
- if (colon(argv[0]) != NULL)
- bump("%s: Remote to remote not supported", argv[0]);
- fh = FindFirstFile(argv[0], &fdat);
- if (fh == INVALID_HANDLE_VALUE)
- bump("%s: No such file or directory\n", argv[0]);
- if (FindNextFile(fh, &fdat))
- targetshouldbedirectory = 1;
- FindClose(fh);
- }
-
- cmd = smalloc(strlen(targ) + 100);
- sprintf(cmd, "scp%s%s%s%s -t %s",
- verbose ? " -v" : "",
- recursive ? " -r" : "",
- preserve ? " -p" : "",
- targetshouldbedirectory ? " -d" : "",
- targ);
- do_cmd(host, user, cmd);
- sfree(cmd);
-
- (void) response();
-
- for (i = 0; i < argc - 1; i++) {
- HANDLE dir;
- WIN32_FIND_DATA fdat;
- src = argv[i];
- if (colon(src) != NULL) {
- fprintf(stderr,
- "%s: Remote to remote not supported\n", src);
- errs++;
- continue;
- }
- dir = FindFirstFile(src, &fdat);
- if (dir == INVALID_HANDLE_VALUE) {
- run_err("%s: No such file or directory", src);
- continue;
- }
- do {
- char *last;
- char namebuf[2048];
- if (strlen(src) + strlen(fdat.cFileName) >=
- sizeof(namebuf)) {
- fprintf(stderr, "%s: Name too long", src);
- continue;
- }
- strcpy(namebuf, src);
- if ((last = strrchr(namebuf, '/')) == NULL)
- last = namebuf;
- else
- last++;
- if (strrchr(last, '\\') != NULL)
- last = strrchr(last, '\\') + 1;
- if (last == namebuf && strrchr(namebuf, ':') != NULL)
- last = strchr(namebuf, ':') + 1;
- strcpy(last, fdat.cFileName);
- source(namebuf);
- } while (FindNextFile(dir, &fdat));
- FindClose(dir);