Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development

Preserving file permissions

(1/3) > >>

dmoore:
I finally got irritated enough by my scripts losing their execute permissions after being saved by C::B that I wrote a little plugin to preserve them:

https://github.com/spillz/codeblocks-python/tree/master/PreservePermissions

Wasn't sure whether to do this as a plugin or as a patch to the save routine in the SDK, so it's a plugin for now.

Notes:
* Linux only, because frankly permissions generally aren't used much on windows by most users, but if someone wants to patch for windows that's fine too.
* Uses system calls stat to get permissions and chmod to set them. It only works for regular save, not save as.

oBFusCATed:
I think it should be fixed in the SDK, no as plugin, because there is a changes for race conditions or sync issues.

dmoore:

--- Quote from: oBFusCATed on March 30, 2014, 01:33:11 pm ---I think it should be fixed in the SDK, no as plugin, because there is a changes for race conditions or sync issues.

--- End quote ---

I was under the impression that NotifyPlugins was blocking and therefore synchronous. So race issues no more or less likely as a plugin I would think. Isn't the existing code already susceptible to arace issues anyway (because access to the original file is never locked) which in practice are never an issue?

But I can show you what a patch to the SDK would look like...

dmoore:
Attached is the alternative of an SDK patch. Wasn't sure what #IFDEF to use, so used __WXGTK__ for now.

Contrary to what I said about "Save As", one potential flaw is that when you overwrite an existing file with Save As, the permissions will be the same as the file you are overwriting. I can't decide if that's good or bad...

oBFusCATed:
A check for platform::unix would probably be better. But you probably need to check for osx, too. I'm not sure what will happen with a cygwin builds thought.
Also the preserve_permissions argument is not used anywhere in the function, nor passed to false. So it should probably not be added.

Navigation

[0] Message Index

[#] Next page

Go to full version