[C0de] var Files: Array of String; S: String; n: Integer; Function StringToArray(Text, Cut: String): array of String; var i, k: Integer; Begin SetArrayLength(Result, 0); if Cut = '' then Cut:= #1310; //если шаблон пуст, считаем переводы строк Repeat k:= Pos(Cut,Text); if k = 1 then begin Delete(Text, 1, Length(Cut)); CONTINUE end; SetArrayLength(Result, GetArrayLength(Result) +1); i:= GetArrayLength(Result) -1; if k = 0 then Result[i]:=Text else begin Result[i]:= Copy(Text, 1, k -1); Delete(Text, 1, Length(Result[i]) + Length(Cut)); end; Until Length(Text) * k = 0; End; procedure FindFiles(FromDir: String; Mask: String); var FSR, DSR: TFindRec; FindResult: Boolean; begin FindResult:= FindFirst(AddBackslash(FromDir)+Mask, FSR) while FindResult do begin if FSR.Attributes and FILE_ATTRIBUTE_DIRECTORY = 0 then begin S:= S + AddBackslash(fromDir) + FSR.Name +'|'; end; FindResult:= FindNext(FSR); end; FindResult:= FindFirst(AddBackslash(FromDir)+ '*.*', DSR) while FindResult do begin if ((DSR.Attributes and FILE_ATTRIBUTE_DIRECTORY) = FILE_ATTRIBUTE_DIRECTORY) and not ((DSR.Name = '.') or (DSR.Name = '..')) then begin FindFiles(AddBackSlash(FromDir)+DSR.Name, Mask) end; FindResult:= FindNext(DSR); end; FindClose(FSR); FindClose(DSR) end; procedure RecodeOgg; var ResultCode: integer; CurFile: String; begin FindFiles(ExpandConstant('{app}'), '*.ogg') //Находим все файлы по маске, в выбранной папке Files:= StringToArray(S, '|') //Переводим в массив WizardForm.ProgressGauge.Max:= GetArrayLength(Files)-1; //Получаем кол-во файлов WizardForm.ProgressGauge.Position:=0 for n:=(GetArrayLength(Files)-1) downto 0 do begin CurFile:= Files[n] StringChange(CurFile, AddBackslash(ExpandConstant('{app}')), '') Exec(ExpandConstant('{app}\oggdec.exe'), '-Q '+AddQuotes(CurFile), '', SW_Hide, EwWaitUntilTerminated, ResultCode) //Для каждого файла запускаем декодер DeleteFile(Files[n]) //Удаляем ненужный файл WizardForm.FilenameLabel.Caption:= Files[n]; //Двигаем прогрессбар WizardForm.ProgressGauge.Position:= WizardForm.ProgressGauge.Position +1; end; DeleteFile(ExpandConstant('{app}\oggdec.exe')) end; procedure CurStepChanged(CurStep: TSetupStep); begin if CurStep = ssPostInstall then RecodeOgg; end; |