GNOME Bugzilla – Bug 550795
[PATCH] GFileCopy flag to preserve permissions of target file in a copy operation
Last modified: 2008-09-22 00:05:45 UTC
Hi!, this feature got added in gnomevfs right before gio appeared, but gio doesn't have it, see bug 309604 for original request of feature in gnomevfs. I want this feature to be able to DnD a folder from a nautilus cdrom window and drop it in my desktop with default perms, so I can put/modify files in it. Currently the folder/files are copied with readonly perms because that are of the source location (cdrom mount). I will file a nautilus bug about that and make it depend on this.
Created attachment 117990 [details] [review] Add GFileCopyFlag Adds a GFileCopyFlag, that flag is read in g_file_copy_attributes(), if it's found then we remove the "unix::mode"[1] attribute from the attributes that are going to be copied to dest file/folder. This is so because file_copy_fallback() first copies the file then sets its attributes (including perms) with a g_file_copy_attributes() from the source to dest. [1] Which is the attribute that carries the perms.
Flag description is: G_FILE_COPY_TARGET_DEFAULT_PERMS: Leaves target file with default perms, instead of setting the source file perms.
The idea makes sense to me, the implementation not so much. Instead of using regex, I'd rather see this being done while assembling the attribute string, inside build_attribute_list_for_copy, or more specifically, should_copy() should pay attention to this flag.
Created attachment 118278 [details] [review] Take two New patch follows Matthias comments, I also like it over the previous one :). Unrelated note Shouldn't glib has a function for replacing strings? when I searched for it my only option was to use g_regex_replace (), which seems overkill just to replace some plain strings.
Stylistically, I slightly prefer bool = foobar & flag != 0 over bool = foobar & flag Other than that, it looks fine.
Actually, I meant: commit after we branch
Ok, I still don't have commit access, so please do it for me.
I will commit it tomorrow morning...
I've just commited the patch so this is fixed :-), thank you!