Skip to content

Commit 195f24d

Browse files
committed
Added a tiered config file location to address permission issues.
1 parent 13ddf3e commit 195f24d

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

Source/devcpp.dpr

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,28 @@ begin
141141
else
142142
devData.INIFileName := IncludeTrailingBackslash(ParamStr(2)) + INIFileName;
143143
end else begin
144-
// default dir should be C:\Users\<username>\Documents\Embarcadero\Dev-Cpp
145-
AppData := IncludeTrailingBackslash(TPath.GetDocumentsPath);
144+
// default dir should be %APPDATA%\Embarcadero\Dev-Cpp
145+
AppData := IncludeTrailingBackslash(TPath.GetHomePath);
146146

147-
// Store the INI file in C:\Users\<username>\Documents or if we are not allowed to do so, in the exe directory
148-
if (not devData.IsPortable) and ((AppData <> '') and (DirectoryExists(AppData + 'Embarcadero\Dev-Cpp') or CreateDir(AppData + 'Embarcadero\Dev-Cpp'))) then
149-
devData.INIFileName := AppData + 'Embarcadero\Dev-Cpp\' + INIFileName
147+
const DevCppDir = 'Embarcadero\Dev-Cpp';
148+
149+
// Store the INI file in %APPDATA% or if we are not allowed to do so, in the exe directory
150+
if (not devData.IsPortable) and ((AppData <> '') and (DirectoryExists(AppData + DevCppDir) or CreateDir(AppData + DevCppDir))) then
151+
devData.INIFileName := AppData + DevCppDir + INIFileName
150152
else
151153
begin
152-
// store it in the default portable config folder anyways...
153-
devData.INIFileName := ExeFolder + 'config\' + INIFileName;
154-
TDirectory.CreateDirectory(TPath.GetDirectoryName(devData.INIFileName));
154+
// default dir should be C:\Users\<username>\Documents\Embarcadero\Dev-Cpp
155+
AppData := IncludeTrailingBackslash(TPath.GetDocumentsPath);
156+
157+
// Store the INI file in C:\Users\<username>\Documents or if we are not allowed to do so, in the exe directory
158+
if (not devData.IsPortable) and ((AppData <> '') and (DirectoryExists(AppData + DevCppDir) or CreateDir(AppData + DevCppDir))) then
159+
devData.INIFileName := AppData + DevCppDir + INIFileName
160+
else
161+
begin
162+
// store it in the default portable config folder anyways...
163+
devData.INIFileName := ExeFolder + 'config\' + INIFileName;
164+
TDirectory.CreateDirectory(TPath.GetDirectoryName(devData.INIFileName));
165+
end;
155166
end;
156167
end;
157168

0 commit comments

Comments
 (0)