Problem with renaming a file

Rajesh Prabhu rp_ece60 at yahoo.co.in
Wed May 24 07:39:27 GMT 2006



Wayne Davison <wayned at samba.org> wrote: On Mon, May 22, 2006 at 08:58:43PM -0700, Rajesh Prabhu wrote:
> Now that im able to get the attribute of a file(whether its hidden or
> not) using attrib.exe, is there a way to transfer such hidden files
> from windows machine to linux machine with a prepended "."?

To do this with the stock rsync, you'd need to script the renaming
yourself somehow.  For instance, create a local copy of the files,
rename the ones that are hidden, and then rsync from the copied files.
Or, rename them in-place, copy them, and then rename them back again
(if that would not disrupt anything).

Another alternative is an old patch named fname-convert.diff.  This
patch was last present in the 2.6.6 release.  I didn't like the design
for a few reasons, including how it would typically need to run a new
convert command for every name.  However, for what you're doing it would
be perfect.  If you created a script that would read a filename on
stdin, check if the file is hidden or not, and then output either the
unchanged filename or the name prepended with a dot, you could use a
patched version of rsync with such a script to accomplish what you want.

Finally, if you want to roll your own, look for the routine make_file()
in flist.c: after the routine copies the name into the "thisname"
buffer, you could modify it however you wish, but you should probably
protect the tweaking-code via "if (am_sender)" so that it doesn't affect
--delete processing when receiving files.

..wayne..
Hi

as you've suggested i tried modifying the value of thisname in flist.c...something like 

    if (strlcpy(thisname, fname, sizeof thisname)
        >= sizeof thisname - flist_dir_len) {
        rprintf(FINFO, "skipping overly long name: %s\n",
            safe_fname(fname));
        return NULL;
    }
        sprintf(thisname,"%s.tmp",thisname);

But this returns an error stating that some files have vanished before they could be transferred. Does this means that file name is sent to the client even before this? Or this change requires  some other change of code too? 

Thanks in advance
Rajesh

		
---------------------------------
Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates.
-------------- next part --------------
HTML attachment scrubbed and removed


More information about the rsync mailing list