* 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
Resourcestring
SErrCouldNotCreatePath = 'Could not create directory "%s"';
const
Brackets : array[0..1] of Char = ('[', ']');
Separator : Char = '=';
@ -922,6 +925,8 @@ procedure TIniFile.UpdateFile;
var
slLines: TStringList;
i, j: integer;
D : String;
begin
slLines := TStringList.Create;
try
@ -944,7 +949,12 @@ begin
slLines.Add('');
end;
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
slLines.SaveToStream(FStream);
FillSectionList(slLines);