Модуль "P2KFileManager" (часть 11) - AddFileToList

Рубрика: Исходники
Среда, 21 апреля 2010 г.
Просмотров: 128
последняя версия: 3.0.9 build 961 beta
от 07 декабря 2007 г.
function TfrmP2KFileManager.AddFileToList(AFile: string; ASize: integer): boolean;
var
  tmpMotoFiles: TMOtoFileList;
  i: integer;
  IsFound: boolean;
  str: string;
  cnt: integer;
begin
  result:= false;
  IsFound:= false;

  //for i:=0 to High(AMotoFiles) do
  for i:=0 to High(xMotoFiles)-1 do
    //if AMotoFiles[i].Name = AFile then begin
    if xMotoFiles[i].Name = AFile then begin
                                              IsFound:= true;
                                              //AMotoFiles[i].Size:= ASize;
                                              xMotoFiles[i].Size:= ASize;
                                              //AMotoFiles[i].Attr:= 0;
                                              xMotoFiles[i].Attr:= 0;
                                              break;
                                            end;
  if IsFound then exit;
  //tmpMotoFiles:= AMotoFiles;
  tmpMotoFiles:= xMotoFiles;
//  cnt:= High(tmpMotoFiles) + 1;
  cnt:= High(tmpMotoFiles) + 2;
  //SetLength(AMotoFiles, cnt);
  SetLength(xMotoFiles, cnt);
  for i:=0 to High(tmpMotoFiles) do
    begin
      //AMotoFiles[i]:= tmpMotoFiles[i];
      xMotoFiles[i]:= tmpMotoFiles[i];
    end;
  //CopyMemory(@AMotoFiles[i].Name, PChar(AFile), length(AFile));
  CopyMemory(@xMotoFiles[i].Name, PChar(AFile), length(AFile));
  str:= AFile;
  str:= ExtractFileExt(str);
  if (str <> '') and (str[1] = '.') then Delete(str, 1, 1);
  //CopyMemory(@AMotoFiles[i].Ext, PChar(str), length(str));
  CopyMemory(@xMotoFiles[i].Ext, PChar(str), length(str));
  //AMotoFiles[i].Size:= ASize;
  xMotoFiles[i].Size:= ASize;
  //AMotoFiles[i].Attr:= 0;
  xMotoFiles[i].Attr:= 0;  
  result:= true;
end;
Rambler's Top100