Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
29th February 2024, 20:56 | #1 | Link |
Registered User
Join Date: Oct 2001
Location: Germany
Posts: 7,277
|
Inno Setup,... need help
I use the following inno setup script: https://pastebin.com/YyibJFk6
Now I want to expand this so that after all the file copying the content of the two files: Code:
{app}\32bit\fonts\local.conf Code:
{app}\64bit\fonts\local.conf Code:
<!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> <dir>APPDATA/HybridFonts</dir> <cachedir>APPDATA/fontconfig/cache</cachedir> </fontconfig> Code:
<!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> <dir>APPDATA/fonts</dir> <cachedir>APPDATA/fontconfig/cache</cachedir> </fontconfig> From what I read online extending the Code-section by: Code:
function ReplaceString(const Source, Find, Replace: string): string; var PosFind: Integer; begin Result := Source; PosFind := Pos(Find, Result); while PosFind > 0 do begin Delete(Result, PosFind, Length(Find)); Insert(Replace, Result, PosFind); PosFind := Pos(Find, Result); end; end; function FileReplaceString(const FileName, SearchString, ReplaceString: string):boolean; var MyFile : TStrings; MyText : string; begin MyFile := TStringList.Create; try result := true; try MyFile.LoadFromFile(FileName); MyText := MyFile.Text; { Only save if text has been changed. } if StringChangeEx(MyText, SearchString, ReplaceString, True) > 0 then begin; MyFile.Text := MyText; MyFile.SaveToFile(FileName); end; except result := false; end; finally MyFile.Free; end; end; function ReplaceLocalConfStrings: Boolean; var AppDataPath: string; LocalConfPath32: string; LocalConfPath64: string; begin Result := True; // Ersetze %appdata% durch %appdata%/.hybrid AppDataPath := ExpandConstant('{userappdata}'); AppDataPath := ReplaceString(AppDataPath, '\', '\\'); AppDataPath := ReplaceString(AppDataPath, 'AppData\Roaming', 'AppData\Roaming\\.hybrid'); // Pfade zu den local.conf-Dateien in den entsprechenden Ordnern LocalConfPath32 := ExpandConstant('{app}\32bit\fonts\local.conf'); LocalConfPath64 := ExpandConstant('{app}\64bit\fonts\local.conf'); // Ersetze die Zeichenfolgen in den Dateien if not FileReplaceString(LocalConfPath32, '<dir>APPDATA/HybridFonts</dir>', '<dir>' + AppDataPath + '\\.hybrid\\HybridFonts</dir>') then Result := False; if not FileReplaceString(LocalConfPath32, '<cachedir>APPDATA/fontconfig/cache</cachedir>', '<cachedir>' + AppDataPath + '\\.hybrid\\fontconfig\\cache</cachedir>') then Result := False; if not FileReplaceString(LocalConfPath64, '<dir>APPDATA/fonts</dir>', '<dir>' + AppDataPath + '\\.hybrid\\fonts</dir>') then Result := False; if not FileReplaceString(LocalConfPath64, '<cachedir>APPDATA/fontconfig/cache</cachedir>', '<cachedir>' + AppDataPath + '\\.hybrid\\fontconfig\\cache</cachedir>') then Result := False; end; I got no clue how this all works, so any help is appreciated. Cu Selur |
1st March 2024, 01:14 | #2 | Link |
*****
Join Date: Feb 2005
Posts: 5,647
|
Don't copy and then modify the files.
Just write simple function to output the desired content to a file. See for example SaveStringToFile or SaveStringsToUTF8File functions in Inno help file.
__________________
MPC-HC 2.2.1 |
Thread Tools | Search this Thread |
Display Modes | |
|
|