diff options
author | Lluis Sanchez Gual <lluis@novell.com> | 2011-04-19 14:41:37 +0400 |
---|---|---|
committer | Lluis Sanchez Gual <lluis@novell.com> | 2011-04-19 14:41:37 +0400 |
commit | a1bc5dce22442d6dfec2c65b77ee997f56ac63fe (patch) | |
tree | b01431ebd44e8545386e45a8b3ebf06cb012d6ca /Mono.Addins.Setup | |
parent | 640b9fec1915a553b57eb49cc1db4866f6e5d818 (diff) |
Simplified write permission check
The old method for checking if a file is writtable will fail if the
file has a write lock, yet a file can be deleted (on unix) even if it
has a write lock. Now we only check that the file is not read only.
There are cases in which some read only file is not writtable (for
example when the user has no permissions). In that case, the
installation will fail later on and will be rolled back.
Diffstat (limited to 'Mono.Addins.Setup')
-rw-r--r-- | Mono.Addins.Setup/Mono.Addins.Setup/AddinStore.cs | 23 |
1 files changed, 2 insertions, 21 deletions
diff --git a/Mono.Addins.Setup/Mono.Addins.Setup/AddinStore.cs b/Mono.Addins.Setup/Mono.Addins.Setup/AddinStore.cs index 9dd5861..60e011a 100644 --- a/Mono.Addins.Setup/Mono.Addins.Setup/AddinStore.cs +++ b/Mono.Addins.Setup/Mono.Addins.Setup/AddinStore.cs @@ -675,27 +675,8 @@ namespace Mono.Addins.Setup internal bool HasWriteAccess (string file) { - if (File.Exists (file)) { - try { - File.OpenWrite (file).Close (); - return true; - } catch { - return false; - } - } - else if (Directory.Exists (file)) { - string tpath = Path.Combine (file, ".test"); - int n = 0; - while (Directory.Exists (tpath + n)) n++; - try { - Directory.CreateDirectory (tpath + n); - Directory.Delete (tpath + n); - return true; - } catch { - return false; - } - } else - return false; + FileInfo f = new FileInfo (file); + return !f.Exists || !f.IsReadOnly; } internal bool IsUserAddin (string addinFile) |