Advertisement
Egor_Vakar

(Delphi) lab 5.1 Lib.dll

Mar 21st, 2022
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.56 KB | None | 0 0
  1. library Lib;
  2.  
  3. uses
  4.   System.SysUtils,
  5.   System.Classes;
  6.  
  7. {$R *.res}
  8.  
  9. function IsInFileCorrect(const Path: String): Boolean; stdcall;
  10. const
  11.     MIN_SIZE = 1;
  12. var
  13.     InFile: TextFile;
  14.     Size, Temp, i: Integer;
  15.     IsCorrect: Boolean;
  16. begin
  17.     IsCorrect := True;
  18.     Try
  19.         AssignFile(InFile, Path);
  20.         Reset(InFile);
  21.         Size := 0;
  22.         try
  23.             Read(InFile,Size);
  24.         except
  25.             IsCorrect := False;
  26.         end;
  27.     except
  28.         IsCorrect := False;
  29.     End;
  30.     if (IsCorrect) then
  31.     begin
  32.         if (Size < MIN_SIZE) then
  33.         begin
  34.             IsCorrect := False;
  35.         end
  36.     end;
  37.     i := 0;
  38.     if IsCorrect then
  39.     begin
  40.         While (IsCorrect and (i < Size) and (not Eof(InFile))) do
  41.         begin
  42.             try
  43.                 Read(InFile, Temp);
  44.             except
  45.                 IsCorrect := False;
  46.             end;
  47.             Inc(i);
  48.         end;
  49.     end;
  50.     if (IsCorrect and((i < Size))) then
  51.     begin
  52.         IsCorrect := False;
  53.     end;
  54.     try
  55.         CloseFile(InFile);
  56.     except
  57.         IsCorrect := False;
  58.     end;
  59.     IsInFileCorrect := IsCorrect;
  60. end;
  61.  
  62. function IsOutFileCorrect(Path: String): Boolean; stdcall;
  63. var
  64.     OutFile: TextFile;
  65.     IsCorrect: Boolean;
  66. begin
  67.     IsCorrect := True;
  68.     try
  69.         AssignFile(OutFile, Path);
  70.         Rewrite(OutFile);
  71.         CloseFile(OutFile);
  72.     except
  73.         IsCorrect := False;
  74.     end;
  75.     IsOutFileCorrect := IsCorrect;
  76. end;
  77.  
  78. exports
  79. IsOutFileCorrect,
  80. IsInFileCorrect;
  81.  
  82. begin
  83. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement