procedure
TForm1
.
Button1Click(Sender: TObject);
const
masRaz =
524288
;
var
sizeF:
Int64
;
sizeFcol:
Int64
;
F, G:
File
;
NameFileF, NameFileG:
string
;
B:
array
[
1..
masRaz]
of
byte
;
i:
integer
;
x:
boolean
;
count:
integer
;
sizeFEnd:
integer
;
function
GetFileSizeAPI(
const
FileName:
string
):
Int64
;
var
FindData: TWin32FindData;
hFind: THandle;
begin
Result := -
1
;
hFind := FindFirstFile(
PChar
(FileName), FindData );
if
hFind <> INVALID_HANDLE_VALUE
then
begin
try
Windows
.
FindClose(hFind);
if
( FindData
.
dwFileAttributes
and
FILE_ATTRIBUTE_DIRECTORY) =
0
then
Result := FindData
.
nFileSizeLow;
except
Result := -
1
;
end
;
end
;
end
;
begin
NameFileF:=
'F:\P1000001.JPG'
;
NameFileG:=
'C:\out.txt'
;
AssignFile(F, NameFileF);
AssignFile(G, NameFileG);
Rewrite(G, masRaz);
sizeF:=
0
;
while
sizeF <=
0
do
begin
sizeF:= GetFileSizeAPI(NameFileF);
sizeFcol:= sizeF
div
masRaz;
sizeFEnd:= sizeF - sizeFcol * masRaz;
end
;
for
i:=
0
to
sizeFcol
do
begin
x:=
false
;
while
not
x
do
begin
Try
FillChar(B, SizeOf(B),
0
);
Reset(F, masRaz);
seek(F, i);
BlockRead(F, B,
1
, count);
CloseFile(F);
if
i <> sizeFcol
then
begin
seek(G, i);
BlockWrite(G, B,
1
);
end
else
begin
CloseFile(G);
FileMode:= fmOpenWrite;
Reset(G,
1
);
Seek(G, (sizeF - sizeFEnd));
BlockWrite(G, B, sizeFEnd);
end
;
x:=
true
;
Except
x:=
false
;
end
;
end
;
end
;
CloseFile(G);
end
;