I have an alternate modification to HostFiles so that a client can learn a file path. It does not make any changes to the implementation, but I change the export marking on the following items.Josef Templ wrote:It is probably worth to consider the export of the startup directory from HostFiles in 1.7.1.
This would be a trivial change and it would not introduce any unwanted side effects
on Locators.
I am not clear whether changing only the implementation with a side effect, or changing only the interface without any implementation changes is the preferred way in the community.
Code: Select all
File* = POINTER TO RECORD (Files.File)
name-: FullName;
PROCEDURE (f: File) FINALIZE-;
PROCEDURE (f: File) NewReader* (old: Files.Reader): Files.Reader;
PROCEDURE (f: File) NewWriter* (old: Files.Writer): Files.Writer;
PROCEDURE (f: File) Length* (): INTEGER;
PROCEDURE (f: File) Flush*;
PROCEDURE (f: File) Register* (name: Files.Name; type: Files.Type; ask: BOOLEAN; OUT res: INTEGER);
PROCEDURE (f: File) Close*;
PROCEDURE (f: File) Closed*(): BOOLEAN;
PROCEDURE (f: File) Shared*(): BOOLEAN;
Code: Select all
(*2016-11-13 alm
I wanted to learn what the server / shadow directory path was. I changes the visibility of HostFiles.File.name to expose that information.
This program tests that behavior. It does it twice because there is an execution path that is unique for a shared previously existing file.
*)
MODULE AlmPath2;
IMPORT
Files, HostFiles, StdLog;
CONST
Loc1 = "Std/Mod"; Name1 = "Api.odc";
Loc2 = "Alm/Mod"; Name2 = "Path.odc";
PROCEDURE ShowAbsoluteFileName*;
VAR
loc : Files.Locator;
f1, f2, f3 : Files.File;
thisName1, thisName2 : HostFiles.FullName;
BEGIN
StdLog.Ln;
loc := Files.dir.This( Loc1 );
f1 := Files.dir.Old( loc, Name1, TRUE );
IF f1=NIL THEN StdLog.String( "file not opened: " ) ELSE StdLog.String( "file opened: ") END;
StdLog.String( "FullName --> " + f1(HostFiles.File ).name$); StdLog.Ln;
StdLog.Ln; StdLog.Ln;
loc := Files.dir.This( Loc2 );
f2 := Files.dir.Old( loc, Name2, TRUE );
IF f2=NIL THEN StdLog.String( "file not opened: " ) ELSE StdLog.String( "file opened: ") END;
StdLog.String( "FullName --> " + f2(HostFiles.File ).name$); StdLog.Ln;
END ShowAbsoluteFileName;
END AlmPath2.
AlmPath2.ShowAbsoluteFileName