Author Topic: Modifying ReadONly file attribute from project manager (patch)  (Read 6756 times)

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Modifying ReadONly file attribute from project manager (patch)
« on: October 20, 2009, 02:40:43 pm »
Attached is a patch that allows changing the read-only attribute of a file through the file properties in the project tab. I need this very often when working with SVN... Probably it's useful for others, too.

Usage: Select a file in you projects, right-click, select "Properties", notice the checkbox at the end which allows you to toggle the state.

Notice: The Unix implementation is untested, but should work and do no harm.

Feedback is welcome!

[attachment deleted by admin]
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Modifying ReadONly file attribute from project manager (patch)
« Reply #1 on: October 21, 2009, 04:03:53 am »
Nice to hear. will test it later ( don't have much time right now )

One thought: what's the difference between your patch and nanyu's plugin.

see here:

http://forums.codeblocks.org/index.php/topic,10163.0.html
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Modifying ReadONly file attribute from project manager (patch)
« Reply #2 on: October 21, 2009, 06:34:34 am »
One thought: what's the difference between your patch and nanyu's plugin.
This plugin sets files automatically to read-only (and only read-only) at editor level. That means the editor that belongs to a file is set read-only to avoid any editing. My patch works on file level (not editor level), thus is really modifies the file attribute to read-only or writable. This is needed in case the file is read-only on the hard disk (usually if under version control like CVS) and you still want to edit it. So there is no editor needed for this operation. Hence it depends on the platform (file system) you are working on.

Actually this should be part of the file manager plugin by dmoore, but it fits nicely into the file properties dialog which cannot be modified by a plugin.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: Modifying ReadONly file attribute from project manager (patch)
« Reply #3 on: October 21, 2009, 07:03:03 am »
@Martin, could you think this is also possible "http://forums.codeblocks.org/index.php/topic,11295.0.html" ?
Then it is even more user friendly, an no right click - properties - check needed ...

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Modifying ReadONly file attribute from project manager (patch)
« Reply #4 on: October 21, 2009, 10:27:43 am »
@Martin, could you think this is also possible "http://forums.codeblocks.org/index.php/topic,11295.0.html" ?
I think this is possible. However, I am not sure if we all agree to do that. As of now we don't modify any attributes at all as they may have a reason. So we assume the file's state is simply set. This is a philosophy we followed so far. What you are suggesting can be really erroneous for these reasons:
- There is no wxWidgets support for doing any file manipulation like that. So we need to implement this ourselves for all platforms.
- However, wxWidgtes support is planned but just not implemented, so most likely we have to change it at a later time.
- What happens if the user does not have the right to change the file's attributes or if they are "virtual" like on network shares under Windows?
- What if these are not files, but links (symlinks)?
- What about user/group/admin rights under Linux/Unix? What flag (file mask) to set exactly?

So - you see: It's easier to leave all that decision to the user and it's favourite file manager. The user knows the state of the file, the permissions and file operations possible to do (on the platform/OS). C::B would need to trial-and-error all the time and we would need to implement quite a complex logic and nearly a tiny file explorer. Still from my daily use I see the benefit as I stumble across this nearly every day. I also see this as a nice feature for the file manager plugin. Maybe it fits better there...

So - I'd like to hear Yiannis words on that.

Ps: That's why I provide this functionality as a patch only btw... not appied to trunk and open for discussion.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Modifying ReadONly file attribute from project manager (patch)
« Reply #5 on: October 21, 2009, 08:59:32 pm »
Actually the read-only flag serves an important and useful purpose (lock reminder) for SVN, so one really shouldn't tamper with that. But then again, do as you like, I'm not using locks anywhere so I shan't be bothered :P

- What happens if the user does not have the right to change the file's attributes or if they are "virtual" like on network shares under Windows?
- What about user/group/admin rights under Linux/Unix? What flag (file mask) to set exactly?
I figure you need to run Code::Blocks as root then  :)
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Modifying ReadONly file attribute from project manager (patch)
« Reply #6 on: October 21, 2009, 09:10:32 pm »
Actually the read-only flag serves an important and useful purpose (lock reminder) for SVN
That is certainly true. But: I am using CVS a lot, too and there removing the lock is as annoying as to run WinCVS (there is no CVS integration for C::B if you remember) and unlock the file. Taking into account that when working on a large project you do that several times it's just annoying!
In the end it's my own repo and a lock makes only sense if working with multiple people which is not the case for me, obviously.
However - I take your comment as a vote against applying to trunk. Still: This feature may be of interest for others, too. So I leave it here as patch (as this was my intention anyways... if you read my posts carefully ;-)).
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

mariocup

  • Guest
Re: Modifying ReadONly file attribute from project manager (patch)
« Reply #7 on: October 21, 2009, 09:42:24 pm »
@Martin,

I think that the status bar could be a better place to show with a "lock icon" that the file is read-only. Since the status bar is always visible it is the perfect place to show some details and it could be also used to modify some settings. For example the spellchecker plugin uses the status bar to switch between different dictionaries. Another use-case could be changing the character encoding of a file via the status bar without wasting time to search the appropriate menu entry.

What are you thinking about it?

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Modifying ReadONly file attribute from project manager (patch)
« Reply #8 on: October 22, 2009, 09:38:31 pm »
But then again, do as you like, I'm not using locks anywhere so I shan't be bothered :P
However - I take your comment as a vote against applying to trunk.
Heh, and I thought we talked the same language :)
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Modifying ReadONly file attribute from project manager (patch)
« Reply #9 on: October 22, 2009, 10:09:30 pm »
Heh, and I thought we talked the same language :)
We do, but this forum is english-only! ;-) :lol: :lol: :lol:

Ok - point taken.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ