Вопрос Как переместить из папки N в папку N\Game?

zettend

Старожил
Здравствуйте!

Мне необходимо сделать что-то подобное:
  1. Создать папку \N\Game
  2. Переместить все файлы, кроме папки Game, из \N в папку \N\Game
P.S. Также как возможно это сделать МЕЖДУ распаковкой архивов game1.bin и game2.bin? Например через ISDone?
 

Krinkels

Он где то тут
Администратор
Ну, для создания/перемещения можно использовать пару замечательных функций
code_language.pascal:
function CreateDir(const Dir: string): Boolean;
function MoveFile(const srcFile, destFile: PChar): Integer; external 'MoveFileA@kernel32.dll stdcall';
 

Andreo Fadio

Старожил
@zettend,
code_language.pascal:
[Setup]
AppName = MyApp
AppVerName = MyApp
DefaultDirname = {pf}\MyApp
OutputDir=.

[Code]
procedure ISMoveDir(const fromDir,toDir,notDir:String);
var
 searchResult: TFindRec;
begin
  if fromDir[Length(fromDir)]<>'\' then fromDir:=fromDir+'\';
  if toDir[Length(toDir)]<>'\' then toDir:=toDir+'\';
  if Pos(notDir, fromDir+searchResult.name) = 0 then ForceDirectories(toDir);
  if FindFirst(fromDir+'*.*', searchResult) then
  begin
    repeat
#ifdef IS_ENHANCED
      Application.ProcessMessages();
#endif
      if ((searchResult.Attributes and FILE_ATTRIBUTE_DIRECTORY ) <> FILE_ATTRIBUTE_DIRECTORY) and (Pos(notDir, fromDir+searchResult.name) = 0) then
      begin
        if FileExists(toDir+searchResult.name) then DeleteFile(toDir+searchResult.name);
        RenameFile(fromDir+searchResult.name, toDir+searchResult.name);
      end else if (searchResult.Name <> '..') and (searchResult.Name <> '.') and (Pos(notDir, fromDir+searchResult.name) = 0) then
       begin
        ISMoveDir(fromDir + searchResult.Name,toDir + searchResult.Name,notDir);
        RemoveDir(fromDir + searchResult.Name);
       end;
    until not FindNext(searchResult);
    FindClose(searchResult);
  end;
end;

function InitializeSetup(): Boolean;
begin
 ISMoveDir(ExpandConstant('{src}\N'),ExpandConstant('{src}\N\Game'),'\Game\');
end;
 

Andreo Fadio

Старожил
P.S. Также как возможно это сделать МЕЖДУ распаковкой архивов game1.bin и game2.bin? Например через ISDone?
Должно сработать
code_language.pascal:
...
if not ISArcExtract ( 0, 0, ExpandConstant('{src}\game1.bin'), ExpandConstant('{app}\N'), '', false, '', '', ExpandConstant('{app}'), notPCFonFLY {PCFonFLY}) then break;
ISMoveDir(ExpandConstant('{app}\N'),ExpandConstant('{app}\N\Game'),'\Game\');
if not ISArcExtract ( 0, 0, ExpandConstant('{src}\game2.bin'), ExpandConstant('{app}\M'), '', false, '', '', ExpandConstant('{app}'), notPCFonFLY {PCFonFLY}) then break;
...
 
Сверху