diff options
| author | Max Howell | 2010-05-10 01:10:49 +0100 |
|---|---|---|
| committer | Adam Vandenberg | 2011-03-12 11:55:04 -0800 |
| commit | 123f7cd00e490bf91d4272b3d4a12041ab3bc4fe (patch) | |
| tree | 6ada3e89af3aade66220e81d333ce94b5d745e06 /Library | |
| parent | 55bd25ff4c270d6146a1df9409ec9c35f76e2fac (diff) | |
| download | brew-123f7cd00e490bf91d4272b3d4a12041ab3bc4fe.tar.bz2 | |
Pathname.ensure_writable
Yields after chmoding (if necessary), once block is complete restores permissions.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/extend/pathname.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index 8b690a258..5534cd752 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -238,6 +238,16 @@ class Pathname def / that join that.to_s end + + def ensure_writable + saved_perms = unless writable? + chmod 0644 + stat.mode + end + yield + ensure + chmod saved_perms if saved_perms + end end # sets $n and $d so you can observe creation of stuff |
