Browse Source

UPD: Allocate space using an independent property

Alexander Koblov 1 year ago
parent
commit
fa9bf4e35b

+ 4 - 3
components/doublecmd/dcclassesutf8.pas

@@ -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);

+ 1 - 1
components/doublecmd/doublecmd_common.lpk

@@ -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"/>

+ 2 - 2
src/filesources/filesystem/ufilesystemutil.pas

@@ -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