mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-02-17 01:22:18 +00:00
Fixed: the old way of checking for GZDB's directory writability would not work in certain versions of WINE/Mono
This commit is contained in:
parent
dceeed6bee
commit
579b90a13c
4 changed files with 21 additions and 29 deletions
|
@ -42,6 +42,8 @@ using CodeImp.DoomBuilder.Types;
|
|||
using CodeImp.DoomBuilder.Windows;
|
||||
using Microsoft.Win32;
|
||||
using SlimDX.Direct3D9;
|
||||
using System.Security;
|
||||
using System.Security.Permissions;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -2135,31 +2137,21 @@ namespace CodeImp.DoomBuilder
|
|||
//mxd
|
||||
public static bool CheckWritePremissions(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
DirectoryInfo di = new DirectoryInfo(path);
|
||||
DirectorySecurity ds = di.GetAccessControl();
|
||||
AuthorizationRuleCollection rules = ds.GetAccessRules(true, true, typeof(NTAccount));
|
||||
WindowsIdentity currentuser = WindowsIdentity.GetCurrent();
|
||||
|
||||
if(currentuser != null)
|
||||
{
|
||||
WindowsPrincipal principal = new WindowsPrincipal(currentuser);
|
||||
foreach(AuthorizationRule rule in rules)
|
||||
{
|
||||
FileSystemAccessRule fsar = rule as FileSystemAccessRule;
|
||||
if(fsar != null && (fsar.FileSystemRights & FileSystemRights.WriteData) > 0)
|
||||
{
|
||||
NTAccount account = rule.IdentityReference as NTAccount;
|
||||
if(account != null && principal.IsInRole(account.Value)) return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(UnauthorizedAccessException) { }
|
||||
|
||||
return false;
|
||||
}
|
||||
try
|
||||
{
|
||||
string testFile = path + "/GZDBWriteTest.tmp";
|
||||
if (File.Exists(testFile))
|
||||
File.Delete(testFile);
|
||||
FileStream fs = File.OpenWrite(testFile);
|
||||
fs.Close();
|
||||
File.Delete(testFile);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace CodeImp.DoomBuilder
|
|||
// Check if we have write access...
|
||||
if(!General.CheckWritePremissions(General.AppPath))
|
||||
{
|
||||
string msg = "Cannot perform update: your user account does not have write access to the destination folder \"" + General.AppPath + "\""
|
||||
string msg = "Cannot perform update: your user account does not have write access to the destination folder \"" + General.AppPath + "\"\n"
|
||||
+ "Move the editor to a folder with write access, or run it as Administrator.";
|
||||
|
||||
if(verbosemode) General.ShowWarningMessage(msg, MessageBoxButtons.OK);
|
||||
|
|
|
@ -30,6 +30,6 @@ using CodeImp.DoomBuilder;
|
|||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("2.3.0.2946")]
|
||||
[assembly: AssemblyVersion("2.3.0.2948")]
|
||||
[assembly: NeutralResourcesLanguageAttribute("en")]
|
||||
[assembly: AssemblyHash("d3b4060")]
|
||||
[assembly: AssemblyHash("dceeed6")]
|
||||
|
|
|
@ -29,5 +29,5 @@ using System.Resources;
|
|||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("2.3.0.2946")]
|
||||
[assembly: AssemblyVersion("2.3.0.2948")]
|
||||
[assembly: NeutralResourcesLanguageAttribute("en")]
|
||||
|
|
Loading…
Reference in a new issue