Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library Lib;
- uses
- System.SysUtils,
- System.Classes;
- {$R *.res}
- function IsInFileCorrect(const Path: String): Boolean; stdcall;
- const
- MIN_SIZE = 1;
- var
- InFile: TextFile;
- Size, Temp, i: Integer;
- IsCorrect: Boolean;
- begin
- IsCorrect := True;
- Try
- AssignFile(InFile, Path);
- Reset(InFile);
- Size := 0;
- try
- Read(InFile,Size);
- except
- IsCorrect := False;
- end;
- except
- IsCorrect := False;
- End;
- if (IsCorrect) then
- begin
- if (Size < MIN_SIZE) then
- begin
- IsCorrect := False;
- end
- end;
- i := 0;
- if IsCorrect then
- begin
- While (IsCorrect and (i < Size) and (not Eof(InFile))) do
- begin
- try
- Read(InFile, Temp);
- except
- IsCorrect := False;
- end;
- Inc(i);
- end;
- end;
- if (IsCorrect and((i < Size))) then
- begin
- IsCorrect := False;
- end;
- try
- CloseFile(InFile);
- except
- IsCorrect := False;
- end;
- IsInFileCorrect := IsCorrect;
- end;
- function IsOutFileCorrect(Path: String): Boolean; stdcall;
- var
- OutFile: TextFile;
- IsCorrect: Boolean;
- begin
- IsCorrect := True;
- try
- AssignFile(OutFile, Path);
- Rewrite(OutFile);
- CloseFile(OutFile);
- except
- IsCorrect := False;
- end;
- IsOutFileCorrect := IsCorrect;
- end;
- exports
- IsOutFileCorrect,
- IsInFileCorrect;
- begin
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement