Menu

Copy directories

SaadB
2012-11-15
2023-09-08
  • SaadB

    SaadB - 2012-11-15

    Can we copy directories and their files

     
  • John Willing

    John Willing - 2023-09-08

    It's over 11 years, I found out that you can with a code fix in client/protocol.c.

    To have tsunamid to be able to send multiple directories/files, launch it with:
    tsunamid find . -type f -print

    This will make all of the files from the find command available to download.

    On the client, tsunami does not handle directories when passed as part of the file. I've updated the code in client/protocol.c aound line 222 (just above the Warning: overwriting...)
    strcpy(local_directory, xfer->local_filename);
    char * slash = rindex(local_directory, '/');
    if ((slash != NULL) && (strlen(slash)>1)) {
    *slash = '\0';
    if (!access(local_directory, F_OK) == 0) {
    printf("Warning: creating directory '%s'\n", local_directory);
    status = mkdir(local_directory, 0777);
    if (status != 0) {
    printf("Error:%d creating directory '%s'\n", errno, local_directory);
    }
    }
    }

    /* try to open the local file for writing */
    if (!access(xfer->local_filename, F_OK))
        printf("Warning: overwriting existing file '%s'\n", local_filename);
    

    This will extract the directory path and create them if it does not exist.
    Then call tsunami and provide the following command:
    connect <host>
    get *</host>

     
  • John Willing

    John Willing - 2023-09-08

    The above find command should have the back quote around it like
    tsunamid find . -type f -print

     

Log in to post a comment.