Menu

[r375]: / trunk / Src / Install / UpdateIni.ps  Maximize  Restore  History

Download this file

160 lines (149 with data), 6.0 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
{
* UpdateIni.ps
*
* Pascal script for use in [Code] Section of CodeSnip's Install.iss.
*
* Creates per-user and application-wide ini files in correct data folders. Can
* also create the ini files from the information stored in the single ini file
* used in versions of CodeSnip prior to version 1.9.
*
* $Rev$
* $Date$
*
* ***** BEGIN LICENSE BLOCK *****
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* The Original Code is UpdateIni.ps.
*
* The Initial Developer of the Original Code is Peter Johnson
* (http://www.delphidabbler.com/).
*
* Portions created by the Initial Developer are Copyright (C) 2007-2009 Peter
* Johnson. All Rights Reserved.
*
* Contributors:
* NONE
*
* ***** END LICENSE BLOCK *****
}
function OriginalIniFileName: string;
{Gets fully specified file name of original style, solitary, config file
(CodeSnip.ini).
@return Ini file name.
}
begin
Result := AddBackslash(gUserAppDataDir) + 'CodeSnip.ini';
end;
function CommonIniFileName: string;
{Gets fully specified file name of current application wide config file
(Common.ini).
@return Ini file name.
}
begin
Result := AddBackslash(gCommonAppDataDir) + 'Common.ini';
end;
function OldUserIniFileName: string;
{Gets fully specified file name of original per user config file (User.ini).
@return Ini file name.
}
begin
Result := AddBackslash(gUserAppDataDir) + 'User.ini';
end;
function UserIniFileName: string;
{Gets fully specified file name of current per user config file (User.3.ini).
@return Ini file name.
}
begin
Result := AddBackslash(gUserAppDataDir) + 'User.3.ini';
end;
procedure StampIniFiles;
{Updates both config files with correct version information. This records ini
file versions and version number of program being installed.
}
begin
// Flag ini file version as version 5
SetIniInt('IniFile', 'Version', 5, UserIniFileName);
SetIniInt('IniFile', 'Version', 5, CommonIniFileName);
// Record application version in common ini file
SetIniString(
'Application',
'Version',
ExpandConstant('{#AppVersion}'),
CommonIniFileName
);
end;
procedure CreateIniFilesFromOldStyle;
{Creates new style per user and common config files from content of single,
old style config file used before CodeSnip v1.9.
}
var
I: Integer; // loops thru all highlight elements
begin
// Create per-user settings file:
// Copy file
FileCopy(OriginalIniFileName, UserIniFileName, False);
// Delete unwanted sections:
// - Application section now in common ini file
// - Source code output format: format lost when updating from CodeSnip pre
// 1.7 since section was SourceOutput, but format preserved from v1.7 since
// current Prefs:SourceCode section used
// - Highlighting style is deliberately lost since CodeSnip v3 has new default
// style and main display uses style, therefore sections HiliteOutput
// (pre v1.7.5) and Prefs:Hiliter (v1.7 and later) deleted
DeleteIniSection('Application', UserIniFileName);
DeleteIniSection('SourceOutput', UserIniFileName);
DeleteIniSection('HiliteOutput', UserIniFileName);
for I := 0 to 11 do
DeleteIniSection('HiliteOutput:Elem' + IntToStr(I), UserIniFileName);
DeleteIniSection('Prefs:Hiliter', UserIniFileName);
// Main window's overview tabs have changed in v3: so we reset to 0 (default)
SetIniInt('MainWindow', 'OverviewTab', 0, UserIniFileName);
// Create common (application specific) settings file
// Copy file
FileCopy(OriginalIniFileName, CommonIniFileName, False);
// Delete unwanted sections
// following sections belong in per-user file
DeleteIniSection('Cmp:D2', CommonIniFileName);
DeleteIniSection('Cmp:D3', CommonIniFileName);
DeleteIniSection('Cmp:D4', CommonIniFileName);
DeleteIniSection('Cmp:D5', CommonIniFileName);
DeleteIniSection('Cmp:D6', CommonIniFileName);
DeleteIniSection('Cmp:D7', CommonIniFileName);
DeleteIniSection('Cmp:D2005w32', CommonIniFileName);
DeleteIniSection('Cmp:D2006w32', CommonIniFileName);
DeleteIniSection('Cmp:D2007', CommonIniFileName);
DeleteIniSection('Cmp:FPC', CommonIniFileName);
DeleteIniSection('FindCompiler', CommonIniFileName);
DeleteIniSection('FindText', CommonIniFileName);
DeleteIniSection('FindXRefs', CommonIniFileName);
DeleteIniSection('MainWindow', CommonIniFileName);
DeleteIniSection('Prefs:General', CommonIniFileName);
DeleteIniSection('Prefs:Printing', CommonIniFileName);
DeleteIniSection('Prefs:SourceCode', CommonIniFileName);
DeleteIniSection('Prefs:Hiliter', CommonIniFileName);
// following sections may occur when updating from CodeSnip v1.7.5 or earlier
DeleteIniSection('SourceOutput', CommonIniFileName);
DeleteIniSection('HiliteOutput', CommonIniFileName);
for I := 0 to 11 do
DeleteIniSection('HiliteOutput:Elem' + IntToStr(I), CommonIniFileName);
end;
procedure CopyOldUserIniFile;
{Copies original per user config file to current location.
}
begin
// Copy the file
FileCopy(OldUserIniFileName, UserIniFileName, False);
// Delete highlighter preferences: not to be brought forward from old versions
DeleteIniSection('Prefs:Hiliter', UserIniFileName);
// Main window's overview tabs have changed in v3: so we reset to 0 (default)
SetIniInt('MainWindow', 'OverviewTab', 0, UserIniFileName);
end;
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.