How would I use this LazUtils Package with just FPC? Is there way to download it by itself? Or would I have to Install Lazarus somewhere, go find the unit and copy it in with all my FPC Units?
I was hoping to do this without doing something like that because then every time I install a new version of FPC, I would have to go back and copy the other units back in, which I probably wouldn’t remember to do right away, but later I would be wondering why I can't re-compile a program used to work that used the other units and then hopefully I would remember where they came from and how and where to copy them.
From: fpc-pascal <[hidden email]> On Behalf Of leledumbo via fpc-pascal
Sent: Thursday, April 18, 2019 2:45 AM
To: [hidden email] Cc: leledumbo <[hidden email]>
Subject: Re: [fpc-pascal] CopyFile for FreePascal without Lazarus?
> but that seems to only work with Lazarus.
The unit is part of LazUtils package. It has no dependency on other packages but indeed can't be used as a standalone unit, you need other units from the same package but that's all.
On 18/04/2019 12:04, James Richters wrote:
> How would I use this LazUtils Package with just FPC?
And with all that discussion and time gone by, you could have simply
implemented it yourself using TFileStream or something like that.
cBlockSize=16384; // size of block if copyfile
function CopyFile(const sSrc, sDst: String; bAppend: Boolean): Boolean;
src: TFileStream = nil;
dst: TFileStream = nil;
iDstBeg:Integer; // in the append mode we store original size
Buffer: PChar = nil;
if not FileExists(sSrc) then
src:=TFileStream.Create(sSrc,fmOpenRead or fmShareDenyNone);
if not Assigned(src) then
if bAppend then
dst.Seek(0,soFromEnd); // seek to end
if not Assigned(dst) then
// we dont't use CopyFrom, because it's alocate and free buffer
every time is called
while (dst.Size+cBlockSize)<= (src.Size+iDstBeg) do
if (iDstBeg+src.Size)>dst.Size then
// unix only - if we want to copy file attributes and permissions
// Result := FileCopyAttr(sSrc, sDst, gDropReadOnlyFlag); // chmod,
on EStreamError do
TfpgMessageDialog.Critical('Error', Format('Cannot copy file
<%s> to <%s>' , [sSrc, sDst]));
if assigned(src) then
if assigned(dst) then
if assigned(Buffer) then
Op 18-04-19 om 13:04 schreef James Richters:
> How would I use this LazUtils Package with just FPC? Is there way to download it by itself? Or would I have to Install Lazarus somewhere, go find the unit and copy it in with all my FPC Units?
Lazutils could also be installed with Fppkg. Just download the sources,
locate the fpmake.pp (components/lazutils) make sure that that directory
is the current directory and run 'fppkg install'.
Thereafter you can use the Lazutils-units in all your fpc-applications.
If you update your compiler (trunk of fixes), call 'fppkg fixbroken' to
re-compile the packages which are installed.
If you update to a really new version of the compiler, you have to
install the package again.