Home Download Buy Blog Forum Support

Saving a read-only file

Re: Saving a read-only file

Postby chbrenne on Tue Jul 02, 2013 11:34 pm

*creepy* Actually, I needed files to stay not read-only. That way later I can easily find files that were modified by me (not received from VCS) to check them in. *creepy*

If you are using Git, you *could* use:
git log --no-merges --stat --author="Pattern" --name-only --pretty=format:"" | sort -u

Taken from: http://stackoverflow.com/questions/6349 ... s-modified. There are some other great suggestions/advices, which might do the trick for what you want to achieve.
chbrenne
 
Posts: 2
Joined: Tue Jul 02, 2013 9:09 pm

Re: Saving a read-only file

Postby hmmdar on Fri Nov 08, 2013 1:01 am

Quick comment on mac(os x 10.8.5) I noticed that without maintaining the current file attrib the file becomes write only, so no read. The following fixes that by just adding write the current attribs map for the user by or'ing the IWRITE with the existing fileAtt.

Code: Select all
import sublime, sublime_plugin, os, stat

class PreSaveCommand(sublime_plugin.EventListener):
    def on_pre_save(self, view):
        myFile = view.file_name()
        fileAtt = os.stat(view.file_name())[0]
        if view.is_dirty():
            if (not fileAtt & stat.S_IWRITE):
                if(sublime.ok_cancel_dialog('The file is Read-Only. Overwrite?', 'Overwrite!')):
                    os.chmod(myFile, stat.S_IWRITE | fileAtt)
hmmdar
 
Posts: 1
Joined: Fri Nov 08, 2013 12:54 am

Re: Saving a read-only file

Postby handycam on Tue Nov 26, 2013 8:39 pm

This latest version ALMOST works perfectly, but I need the file to end up being set read-only like it was before I started. How can I change the plugin?

Never mind, it would seem that Visual Studio ALSO leaves the file no longer read-only.
Mac OS 10.9.3
ST 3 (3059)
handycam
 
Posts: 271
Joined: Tue Jan 03, 2012 2:42 pm

Re: Saving a read-only file

Postby handycam on Tue Nov 26, 2013 8:43 pm

In case anyone is wondering why I need to do this, we are using IBM ClearCase and VS 2012 and so far the version control does not fully integrate so we work in VS in "temporarily offline" mode. And I despise VS and want to work in ST3.
Mac OS 10.9.3
ST 3 (3059)
handycam
 
Posts: 271
Joined: Tue Jan 03, 2012 2:42 pm

Previous

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 15 guests