* Attempt to create directory, fail if not possible

git-svn-id: trunk@23593 -
This commit is contained in:
michael 2013-02-11 08:15:13 +00:00
parent 1b9842c33a
commit aca21b0b60

View File

@ -198,6 +198,9 @@ type
implementation implementation
Resourcestring
SErrCouldNotCreatePath = 'Could not create directory "%s"';
const const
Brackets : array[0..1] of Char = ('[', ']'); Brackets : array[0..1] of Char = ('[', ']');
Separator : Char = '='; Separator : Char = '=';
@ -922,6 +925,8 @@ procedure TIniFile.UpdateFile;
var var
slLines: TStringList; slLines: TStringList;
i, j: integer; i, j: integer;
D : String;
begin begin
slLines := TStringList.Create; slLines := TStringList.Create;
try try
@ -944,7 +949,12 @@ begin
slLines.Add(''); slLines.Add('');
end; end;
if FFileName > '' then if FFileName > '' then
slLines.SaveToFile(FFileName) begin
D:=ExtractFilePath(FFileName);
if not ForceDirectories(D) then
Raise EInoutError.CreateFmt(SErrCouldNotCreatePath,[D]);
slLines.SaveToFile(FFileName);
end
else if FStream <> nil then else if FStream <> nil then
slLines.SaveToStream(FStream); slLines.SaveToStream(FStream);
FillSectionList(slLines); FillSectionList(slLines);