Rev 1 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1 | Rev 4 | ||
---|---|---|---|
Line 8... | Line 8... | ||
8 | uses |
8 | uses |
9 | SysUtils, |
9 | SysUtils, |
10 | Windows, |
10 | Windows, |
11 | Classes, |
11 | Classes, |
12 | ZipMstr19, |
12 | ZipMstr19, |
- | 13 | Dialogs, |
|
13 | Functions in 'Functions.pas', |
14 | Functions in 'Functions.pas', |
14 | SFXBehavior in 'SFXBehavior.pas'; |
15 | SFXBehavior in 'SFXBehavior.pas'; |
15 | 16 | ||
16 | const |
17 | const |
17 | Extractor_EXE = 'Extractor.exe'; |
18 | Extractor_EXE = 'Extractor.exe'; |
18 | SIGN_BAT = 'Tools\VTSSign.bat'; |
19 | SIGN_BAT = 'Tools\VTSSign.bat'; |
19 | ZIP_EXE = 'Tools\zip.exe'; |
20 | ZIP_EXE = 'Tools\zip.exe'; |
20 | RemoveSignature_EXE = 'Tools\RemoveSignature.exe'; |
21 | RemoveSignature_EXE = 'Tools\RemoveSignature.exe'; |
21 | 22 | ||
- | 23 | procedure DoMakeSFX(AFilename: string); |
|
22 | var |
24 | var |
23 | Src, Dst: string; |
25 | Dst: string; |
24 | i: integer; |
- | |
25 | s1, s2: TFileStream; |
26 | s1, s2: TFileStream; |
26 | x: TZipMaster19; |
27 | x: TZipMaster19; |
27 | - | ||
28 | resourcestring |
28 | resourcestring |
29 | ImportantFileNotFound = 'Error: Important file "%s" not found!'; |
- | |
30 | LngErrorWhileCopy = 'Error: Could not copy "%s" to "%s".'; |
29 | LngErrorWhileCopy = 'Error: Could not copy "%s" to "%s".'; |
31 | LngErrorWhileExecuting = 'Error while executing "%s".'; |
30 | LngErrorWhileExecuting = 'Error while executing "%s".'; |
32 | SourceFileNotFound = 'Source file "%s" not found.'; |
31 | SourceFileNotFound = 'Source file "%s" not found.'; |
33 | Lng_In = 'Input:'; |
32 | Lng_In = 'Input:'; |
34 | Lng_Out = 'Output:'; |
33 | Lng_Out = 'Output:'; |
Line 36... | Line 35... | ||
36 | Lng_Append = 'Append ZIP to Extractor template...'; |
35 | Lng_Append = 'Append ZIP to Extractor template...'; |
37 | Lng_Adjust = 'Adjust the ZIP offset of the SFX...'; |
36 | Lng_Adjust = 'Adjust the ZIP offset of the SFX...'; |
38 | Lng_ModifyZIPComment = 'Modify ZIP Comment...'; |
37 | Lng_ModifyZIPComment = 'Modify ZIP Comment...'; |
39 | Lng_SignSfx = 'Sign the SFX...'; |
38 | Lng_SignSfx = 'Sign the SFX...'; |
40 | Lng_Finished = 'Finished! :-)'; |
39 | Lng_Finished = 'Finished! :-)'; |
41 | Lng_Title = 'ViaThinkSoft AutoSFX'; |
- | |
42 | Lng_Usage1 = 'Usage:'; |
- | |
43 | Lng_Usage2 = 'MakeSFX [File1.zip [File2.zip...]]'; |
- | |
44 | - | ||
45 | {$R *.res} |
- | |
46 | - | ||
47 | begin |
40 | begin |
48 | WriteLn(Lng_Title); |
- | |
49 | WriteLn(''); |
- | |
50 | WriteLn(Lng_Usage1); |
- | |
51 | WriteLn(Lng_Usage2); |
- | |
52 | WriteLn(''); |
- | |
53 | - | ||
54 | if not FileExists(ExtractFilePath(ParamStr(0)) + Extractor_EXE) then |
41 | if not FileExists(AFilename) then |
55 | begin |
42 | begin |
56 | WriteLn(Format(ImportantFileNotFound, [Extractor_EXE])); |
- | |
57 | {$IFDEF DELAY_ON_ERROR} |
- | |
58 | Sleep(2000); |
- | |
59 | {$ENDIF} |
- | |
60 | ExitCode := 2; |
- | |
61 | Exit; |
- | |
62 | end; |
- | |
63 | - | ||
64 | for i := 1 to ParamCount do |
- | |
65 | begin |
- | |
66 | Src := ParamStr(i); |
- | |
67 | - | ||
68 | if not FileExists(Src) then |
- | |
69 | begin |
- | |
70 | WriteLn(Format(SourceFileNotFound, [Src])); |
43 | WriteLn(Format(SourceFileNotFound, [AFilename])); |
71 | {$IFDEF DELAY_ON_ERROR} |
44 | {$IFDEF DELAY_ON_ERROR} |
72 | Sleep(2000); |
45 | Sleep(2000); |
73 | {$ENDIF} |
46 | {$ENDIF} |
74 | ExitCode := 1; |
47 | ExitCode := 1; |
75 | Continue; |
48 | Exit; |
76 | end; |
49 | end; |
77 | 50 | ||
78 | Dst := ChangeFileExt(Src, '.exe'); |
51 | Dst := ChangeFileExt(AFilename, '.exe'); |
79 | 52 | ||
80 | WriteLn(Format(Lng_In+#9+'%s', [Src])); |
53 | WriteLn(Format(Lng_In+#9+'%s', [AFilename])); |
81 | WriteLn(Format(Lng_Out+#9+'%s', [Dst])); |
54 | WriteLn(Format(Lng_Out+#9+'%s', [Dst])); |
82 | WriteLn(''); |
55 | WriteLn(''); |
83 | 56 | ||
84 | if not RawFileCopy(ExtractFilePath(ParamStr(0)) + Extractor_EXE, Dst) then |
57 | if not RawFileCopy(ExtractFilePath(ParamStr(0)) + Extractor_EXE, Dst) then |
85 | begin |
58 | begin |
86 | WriteLn(Format(LngErrorWhileCopy, [Extractor_EXE, Dst])); |
59 | WriteLn(Format(LngErrorWhileCopy, [Extractor_EXE, Dst])); |
87 | {$IFDEF DELAY_ON_ERROR} |
60 | {$IFDEF DELAY_ON_ERROR} |
88 | Sleep(2000); |
61 | Sleep(2000); |
89 | {$ENDIF} |
62 | {$ENDIF} |
90 | ExitCode := 1; |
63 | ExitCode := 1; |
91 | Continue; |
64 | Exit; |
92 | end; |
65 | end; |
93 | 66 | ||
94 | // Remove the signature of Extractor first (otherwise signing will fail later) |
67 | // Remove the signature of Extractor first (otherwise signing will fail later) |
95 | 68 | ||
96 | WriteLn(#9 + Lng_RemoveSig); |
69 | WriteLn(#9 + Lng_RemoveSig); |
Line 102... | Line 75... | ||
102 | DeleteFile(PChar(Dst)); |
75 | DeleteFile(PChar(Dst)); |
103 | {$IFDEF DELAY_ON_ERROR} |
76 | {$IFDEF DELAY_ON_ERROR} |
104 | Sleep(2000); |
77 | Sleep(2000); |
105 | {$ENDIF} |
78 | {$ENDIF} |
106 | ExitCode := 1; |
79 | ExitCode := 1; |
107 | Continue; |
80 | Exit; |
108 | {$ENDIF} |
81 | {$ENDIF} |
109 | end; |
82 | end; |
110 | 83 | ||
111 | WriteLn(#9 + Lng_Append); |
84 | WriteLn(#9 + Lng_Append); |
112 | 85 | ||
113 | s1 := TFileStream.Create(Dst, fmOpenWrite); |
86 | s1 := TFileStream.Create(Dst, fmOpenWrite); |
114 | try |
87 | try |
115 | s1.Seek(0, soEnd); |
88 | s1.Seek(0, soEnd); |
116 | 89 | ||
117 | s2 := TFileStream.Create(Src, fmOpenRead or fmShareDenyWrite); |
90 | s2 := TFileStream.Create(AFilename, fmOpenRead or fmShareDenyWrite); |
118 | try |
91 | try |
119 | s1.CopyFrom(s2, s2.Size); |
92 | s1.CopyFrom(s2, s2.Size); |
120 | finally |
93 | finally |
121 | s2.Free; |
94 | s2.Free; |
122 | end; |
95 | end; |
Line 132... | Line 105... | ||
132 | WriteLn(Format(LngErrorWhileExecuting, [ZIP_EXE])); |
105 | WriteLn(Format(LngErrorWhileExecuting, [ZIP_EXE])); |
133 | {$IFDEF DELAY_ON_ERROR} |
106 | {$IFDEF DELAY_ON_ERROR} |
134 | Sleep(2000); |
107 | Sleep(2000); |
135 | {$ENDIF} |
108 | {$ENDIF} |
136 | ExitCode := 1; |
109 | ExitCode := 1; |
137 | Continue; |
110 | Exit; |
138 | end; |
111 | end; |
139 | 112 | ||
140 | WriteLn(#9 + Lng_ModifyZIPComment); |
113 | WriteLn(#9 + Lng_ModifyZIPComment); |
141 | 114 | ||
142 | x := TZipMaster19.Create(nil); |
115 | x := TZipMaster19.Create(nil); |
Line 175... | Line 148... | ||
175 | DeleteFile(PChar(Dst)); |
148 | DeleteFile(PChar(Dst)); |
176 | {$IFDEF DELAY_ON_ERROR} |
149 | {$IFDEF DELAY_ON_ERROR} |
177 | Sleep(2000); |
150 | Sleep(2000); |
178 | {$ENDIF} |
151 | {$ENDIF} |
179 | ExitCode := 1; |
152 | ExitCode := 1; |
180 | Continue; |
153 | Exit; |
181 | {$ENDIF} |
154 | {$ENDIF} |
182 | end; |
155 | end; |
183 | 156 | ||
184 | WriteLn(#9 + Lng_Finished); |
157 | WriteLn(#9 + Lng_Finished); |
185 | WriteLn(''); |
158 | WriteLn(''); |
186 | end; |
159 | end; |
187 | 160 | ||
- | 161 | {$R *.res} |
|
- | 162 | ||
- | 163 | var |
|
- | 164 | i: integer; |
|
- | 165 | od: TOpenDialog; |
|
- | 166 | resourcestring |
|
- | 167 | Lng_Title = 'ViaThinkSoft AutoSFX'; |
|
- | 168 | Lng_Usage1 = 'Usage:'; |
|
- | 169 | Lng_Usage2 = 'MakeSFX [File1.zip [File2.zip...]]'; |
|
- | 170 | ImportantFileNotFound = 'Error: Important file "%s" not found!'; |
|
- | 171 | begin |
|
- | 172 | WriteLn(Lng_Title); |
|
- | 173 | WriteLn(''); |
|
- | 174 | WriteLn(Lng_Usage1); |
|
- | 175 | WriteLn(Lng_Usage2); |
|
- | 176 | WriteLn(''); |
|
- | 177 | ||
- | 178 | if not FileExists(ExtractFilePath(ParamStr(0)) + Extractor_EXE) then |
|
- | 179 | begin |
|
- | 180 | WriteLn(Format(ImportantFileNotFound, [Extractor_EXE])); |
|
- | 181 | {$IFDEF DELAY_ON_ERROR} |
|
- | 182 | Sleep(2000); |
|
- | 183 | {$ENDIF} |
|
- | 184 | ExitCode := 2; |
|
- | 185 | Exit; |
|
- | 186 | end; |
|
- | 187 | ||
- | 188 | if ParamCount = 0 then |
|
- | 189 | begin |
|
- | 190 | od := TOpenDialog.Create(nil); |
|
- | 191 | try |
|
- | 192 | od.DefaultExt := '.zip'; |
|
- | 193 | od.Filter := 'ZIP-Archiv (*.zip)|*.zip|Alle Dateien (*.*)|*.*'; |
|
- | 194 | od.Options := [ofAllowMultiSelect, ofFileMustExist, ofHideReadOnly, |
|
- | 195 | ofPathMustExist, ofEnableSizing]; |
|
- | 196 | if od.Execute then |
|
- | 197 | begin |
|
- | 198 | for i := 0 to od.Files.Count - 1 do |
|
- | 199 | begin |
|
- | 200 | DoMakeSFX(od.Files.Strings[i]); |
|
- | 201 | end; |
|
- | 202 | end; |
|
- | 203 | finally |
|
- | 204 | od.Free; |
|
- | 205 | end; |
|
- | 206 | end |
|
- | 207 | else |
|
- | 208 | begin |
|
- | 209 | for i := 1 to ParamCount do |
|
- | 210 | begin |
|
- | 211 | DoMakeSFX(ParamStr(i)); |
|
- | 212 | end; |
|
- | 213 | end; |
|
- | 214 | ||
188 | // TODO: Es gibt bei Win2000 außerhalb des debuggers eine AV... |
215 | // TODO: Es gibt bei Win2000 außerhalb des debuggers eine AV... |
189 | end. |
216 | end. |