[Lazarus] tail on windows

Mattias Gaertner nc-gaertnma at netcologne.de
Sat Jul 17 17:42:36 CEST 2010


On Sat, 17 Jul 2010 14:33:03 +0000
dmitry boyarintsev <skalogryz.lists at gmail.com> wrote:

> To make the file sharable at Windows you need to apply this patch to
> lcl proc (and eventually rebuild LCL and Lazarus):
> After that any program can read/write to the logging file

Is it really that complicated under windows to open a file shared
readable?
Why is an Assign, Close, Assign, Append needed?


Mattias


> 
> Index: lclproc.pas
> ===================================================================
> --- lclproc.pas	(revision 26528)
> +++ lclproc.pas	(working copy)
> @@ -2051,6 +2051,8 @@
>        Result := ExpandFileNameUTF8(Result);
>    end;
> 
> +var
> +  fm: Byte;
>  begin
>    DebugText := nil;
>    DebugFileName := GetDebugFileName;
> @@ -2058,11 +2060,19 @@
>      (DirPathExists(ExtractFileDir(DebugFileName))) then begin
>      new(DebugText);
>      try
> +      fm:=Filemode;
> +      FileMode:=fmShareDenyNone;
>        Assign(DebugText^, DebugFileName);
>        if FileExistsUTF8(DebugFileName) then
>          Append(DebugText^)
> -      else
> +      else begin
>          Rewrite(DebugText^);
> +        // recreating the file to be sharable!
> +        Close(DebugText^);
> +        Assign(DebugText^, DebugFileName);
> +        Append(DebugText^)
> +      end;
> +      Filemode:=fm;
>      except
>        Freemem(DebugText);
>        DebugText := nil;




More information about the Lazarus mailing list