Skip to content

Commit b7984ac

Browse files
committed
Fix a logic problem with the permission check where the directory does not exist yet at the install time and thus inappropriately asks for admin privileges.
1 parent 526fc6f commit b7984ac

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

Rubberduck.Deployment/InnoSetup/Installer Build Script.iss

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,25 @@ end;
254254
///</remarks>
255255
function HaveWriteAccessToApp: Boolean;
256256
var
257+
PathName: string;
257258
FileName: string;
258259
begin
259-
FileName := AddBackslash(WizardDirValue) + 'writetest.tmp';
260+
261+
//DirExists() will return true if the path has a ending backslash
262+
//so we must take care to remove the backslash while we locate a
263+
//existent directory to avoid trying to create a file to a directory
264+
//that doesn't exists. We can assume that if we can create a file in
265+
//the first existent directory, we should be able to create directories
266+
PathName := RemoveBackslash(WizardDirValue);
267+
Log('Starting PathName: ' + PathName);
268+
269+
while not DirExists(PathName) do
270+
begin
271+
PathName := RemoveBackSlash(ExtractFilePath(PathName));
272+
Log('Modified PathName: ' + PathName);
273+
end;
274+
275+
FileName := AddBackSlash(PathName) + 'writetest.tmp';
260276
Result := SaveStringToFile(FileName, 'test', False);
261277
if Result then
262278
begin

0 commit comments

Comments
 (0)