Subversion Repositories autosfx

Rev

Rev 3 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3 Rev 5
Line 1... Line 1...
1
unit ExtractorMain;
1
unit ExtractorMain;
2
 
2
 
3
{$DEFINE USE_DZIP_UNPACK}
3
{$DEFINE USE_DZIP_UNPACK} // recommended
4
 
4
 
5
interface
5
interface
6
 
6
 
7
uses
7
uses
8
  Windows, SysUtils, Classes, Controls, Forms, Dialogs, StdCtrls, ShellAPI,
8
  Windows, SysUtils, Classes, Controls, Forms, Dialogs, StdCtrls, ShellAPI,
Line 147... Line 147...
147
  l: TStringList;
147
  l: TStringList;
148
  s: string;
148
  s: string;
149
  ec: Integer;
149
  ec: Integer;
150
  ar: TExecuteSFXAutoRunResult;
150
  ar: TExecuteSFXAutoRunResult;
151
  GeneralBaseDir: string;
151
  GeneralBaseDir: string;
-
 
152
  ok: boolean;
152
const
153
const
153
  C_Explorer_Open_Param = '"%s"';
154
  C_Explorer_Open_Param = '"%s"';
154
  C_Explorer_Select_Param = '/n,/select,"%s"';
155
  C_Explorer_Select_Param = '/n,/select,"%s"';
155
  EXPLORER_EXE = 'explorer';
156
  EXPLORER_EXE = 'explorer';
156
resourcestring
157
resourcestring
157
  Lng_Aborted = 'Der laufende Prozess wurde abgebrochen. Das extrahierten Dateien sind somit unvollständig.';
158
  Lng_Aborted = 'Der laufende Prozess wurde abgebrochen. Das extrahierten Dateien sind somit unvollständig.';
158
  Lng_Zip_Error = 'ZIP-Master Fehler "%s" (%d)';
159
  Lng_Zip_Error = 'ZIP-Master Fehler "%s" (%d)';
159
  Lng_AutoRunFailed = 'SFX-AutoRun fehlgeschlagen. Die entpackten Inhalte werden nun angezeigt.';
160
  Lng_AutoRunFailed = 'SFX-AutoRun fehlgeschlagen. Die entpackten Inhalte werden nun angezeigt.';
160
  Lng_Unknown_Error = 'Unbekannter Fehler: Dateien sind nicht aufzufinden!';
161
  Lng_Unknown_Error = 'Unbekannter Fehler: Dateien sind nicht aufzufinden!';
161
  Lng_SelectDir = 'Bitte wählen Sie ein Verzeichnis zum Extrahieren aus. Es wird maximal 1 Datei bzw. Ordner erstellt!';
162
  Lng_SelectDir = 'Bitte wählen Sie ein Verzeichnis zum Extrahieren aus. Es wird maximal 1 Datei bzw. Ordner erstellt!';
-
 
163
  Lng_WriteProtected = 'Das Verzeichnis ist nicht schreibbar! Bitte wählen Sie ein Anderes.';
162
begin
164
begin
163
  AZipfile := ExpandUNCFileName(AZipfile);
165
  AZipfile := ExpandUNCFileName(AZipfile);
164
  RenamingOldPrefix := '';
166
  RenamingOldPrefix := '';
165
  RenamingNewPrefix := '';
167
  RenamingNewPrefix := '';
166
 
168
 
Line 192... Line 194...
192
    uz.OnSetExtName := EvExtFNChange;
194
    uz.OnSetExtName := EvExtFNChange;
193
 
195
 
194
    // Find out base dirtory
196
    // Find out base dirtory
195
 
197
 
196
    GeneralBaseDir := '';
198
    GeneralBaseDir := '';
-
 
199
 
197
    case zb.ExtractionTarget of
200
    if zb.ExtractionTarget = etExtractHere then
198
      etExtractHere:
-
 
199
        begin
201
    begin
200
          GeneralBaseDir := ExtractFilePath(AZipfile); // Default
202
      GeneralBaseDir := ExtractFilePath(AZipfile); // Default
-
 
203
 
-
 
204
      if not IsDirectoryWritable(GeneralBaseDir) or
-
 
205
         IsAtFlobbyDisk(GeneralBaseDir) then
-
 
206
      begin
-
 
207
        zb.ExtractionTarget := etDesktop;
201
        end;
208
      end;
202
      etDesktop:
209
    end;
-
 
210
 
-
 
211
    if zb.ExtractionTarget = etDesktop then
203
        begin
212
    begin
204
          GeneralBaseDir := GetSpecialFolderPath(CSIDL_DESKTOP);
213
      GeneralBaseDir := GetSpecialFolderPath(CSIDL_DESKTOP);
-
 
214
 
-
 
215
      if not IsDirectoryWritable(GeneralBaseDir) or
-
 
216
         IsAtFlobbyDisk(GeneralBaseDir) then
-
 
217
      begin
-
 
218
        zb.ExtractionTarget := etAsk;
-
 
219
      end;
205
        end;
220
    end;
-
 
221
 
206
      etAsk:
222
    if zb.ExtractionTarget = etAsk then
207
        begin
223
    begin
-
 
224
      repeat
208
          GeneralBaseDir := MySelectDirectory(Lng_SelectDir);
225
        GeneralBaseDir := MySelectDirectory(Lng_SelectDir);
209
          if GeneralBaseDir = '' then Exit;
226
        if GeneralBaseDir = '' then Exit;
-
 
227
 
-
 
228
        ok := IsDirectoryWritable(GeneralBaseDir);
-
 
229
        if not ok then
-
 
230
        begin
-
 
231
          MessageDlg(Lng_WriteProtected, mtWarning, [mbOk], 0);
210
        end;
232
        end;
-
 
233
      until ok;
211
    end;
234
    end;
-
 
235
 
212
    GeneralBaseDir := IncludeTrailingPathDelimiter(GeneralBaseDir);
236
    GeneralBaseDir := IncludeTrailingPathDelimiter(GeneralBaseDir);
213
 
237
 
214
    // Semantic scanning of ZIP to determinate the final extraction directory
238
    // Semantic scanning of ZIP to determinate the final extraction directory
215
 
239
 
216
    l := TStringList.Create;
240
    l := TStringList.Create;
Line 283... Line 307...
283
 
307
 
284
      // Errors?
308
      // Errors?
285
 
309
 
286
      if ErrorForm.ErrorsAvailable then
310
      if ErrorForm.ErrorsAvailable then
287
      begin
311
      begin
-
 
312
        Hide;
288
        ErrorForm.ShowModal;
313
        ErrorForm.ShowModal;
289
      end;
314
      end;
290
 
315
 
291
      // Show After-Extracting comment?
316
      // Show After-Extracting comment?
292
 
317
 
Line 609... Line 634...
609
  if (SkipType = stBadPassword) and not StopAskingPassword then
634
  if (SkipType = stBadPassword) and not StopAskingPassword then
610
  begin
635
  begin
611
    MessageDlg(Format(Lng_PasswordWrong, [ForFile]), mtError, [mbOk], 0);
636
    MessageDlg(Format(Lng_PasswordWrong, [ForFile]), mtError, [mbOk], 0);
612
    LastTriedPassword := '';
637
    LastTriedPassword := '';
613
  end;
638
  end;
614
  ErrorForm.NewError(StripBaseDir(ForFile));
639
  ErrorForm.NewError(ForFile, SkipType);
615
end;
640
end;
616
 
641
 
617
end.
642
end.