UPD: Allocate space using an independent property

This commit is contained in:
Alexander Koblov 2024-09-16 23:56:50 +03:00
commit fa9bf4e35b
3 changed files with 7 additions and 6 deletions

View file

@ -42,7 +42,7 @@ type
protected
FFileName: String;
procedure Sync(AWritten: Int64);
procedure SetSize64(const NewSize: Int64); override;
procedure SetCapacity(const NewCapacity: Int64);
public
constructor Create(const AFileName: String; Mode: LongWord); virtual; overload;
destructor Destroy; override;
@ -51,6 +51,7 @@ type
function Write(const Buffer; Count: LongInt): LongInt; override;
property DirtyLimit: Int64 read FDirtyLimit write FDirtyLimit;
property AutoSync: Boolean read FAutoSync write SetAutoSync;
property Capacity: Int64 write SetCapacity;
property FileName: String read FFileName;
end;
@ -156,9 +157,9 @@ begin
end;
end;
procedure TFileStreamEx.SetSize64(const NewSize: Int64);
procedure TFileStreamEx.SetCapacity(const NewCapacity: Int64);
begin
FileAllocate(Handle, NewSize);
FileAllocate(Handle, NewCapacity);
end;
constructor TFileStreamEx.Create(const AFileName: String; Mode: LongWord);

View file

@ -36,7 +36,7 @@ end"/>
</CompilerOptions>
<Description Value="Common units for Double Commander"/>
<License Value="GNU GPL 2"/>
<Version Minor="4" Release="1"/>
<Version Minor="4" Release="2"/>
<Files Count="12">
<Item1>
<Filename Value="dcclassesutf8.pas"/>

View file

@ -615,7 +615,7 @@ var
TotalBytesToRead := SourceFileStream.Size;
if FReserveSpace then
begin
TargetFileStream.Size:= SourceFileStream.Size;
TargetFileStream.Capacity:= SourceFileStream.Size;
TargetFileStream.Seek(0, fsFromBeginning);
end;
end;
@ -759,7 +759,7 @@ begin
if FReserveSpace then
begin
TargetFileStream.Size:= SourceFileStream.Size;
TargetFileStream.Capacity:= SourceFileStream.Size;
TargetFileStream.Seek(0, fsFromBeginning);
end;
end else