User forums > General (but related to Code::Blocks)
Linux file save permission bug
schickb:
Using CB 8.02 on Ubuntu 8.10 beta.
I opened a python file with permissions of rwxr-xr-x in CB. I edited the file and saved it, and found the permissions set to rw-r--r--. Each time I save the file, CB seems to trash the current permissions and set them back to the default umask.
BTW, CB is by far the best open source IDE I've tried. The symbol engine for C is great.
Jenna:
I can confirm this.
I think it happens, because C::B creates a backup-file, saves the changes to a new file and then replaces the original-file with the new on, but it does not touch the umask. So the standard umask will also be used.
Jenna:
I didn't find an easy way to get and set the permissions of a file with wxWidgets.
So I created a short patch that copies and renames the original file, instead of creating a new (empty) one.
It might not be the most elegant way, I think, but it works and it does not change any other function.
--- Code: ------ codeblocks-1.0svn.orig/src/sdk/filemanager.cpp 2008-03-01 09:23:55.000000000 +0100
+++ codeblocks-1.0svn.work/src/sdk/filemanager.cpp 2008-03-30 19:18:01.000000000 +0200
@@ -309,6 +309,10 @@
wxString tempName(name + _T(".cbTemp"));
do
{
+ if(wxRenameFile(name, tempName) == false)
+ return false;
+ if(wxCopyFile(tempName, name) ==false)
+ return false;
wxFile f(tempName, wxFile::write);
if(!f.IsOpened())
return false;
--- End code ---
schickb:
Thanks. I haven't build CB from source yet, but I guess I will since this bug makes editing python scripts annoying. Or I see that your site has .deps, have you applied this patch there?
DrewBoo:
--- Quote from: jens on March 30, 2008, 07:32:21 pm ---I didn't find an easy way to get and set the permissions of a file with wxWidgets.
So I created a short patch that copies and renames the original file, instead of creating a new (empty) one.
It might not be the most elegant way, I think, but it works and it does not change any other function.
--- End quote ---
Have you checked if wxCopyFile copies the attributes?
If it does, this tweak of your patch would work.
(I'm not changing your patch just for the sake of changing it. I'm concerned that the added code in the patch above could succeed with wxFileRename and fail with wxCopyFile and then your file is mysteriously missing. See what I'm saying?)
--- Code: ------ codeblocks-1.0svn.orig/src/sdk/filemanager.cpp 2008-03-01 09:23:55.000000000 +0100
+++ codeblocks-1.0svn.work/src/sdk/filemanager.cpp 2008-03-30 19:18:01.000000000 +0200
@@ -309,6 +309,8 @@
wxString tempName(name + _T(".cbTemp"));
do
{
+ if(wxCopyFile(name, tempName) ==false)
+ return false;
wxFile f(tempName, wxFile::write);
if(!f.IsOpened())
return false;
--- End code ---
Navigation
[0] Message Index
[#] Next page
Go to full version