Hello Fred, you wrote on Fri, 8 Sep 2023 17:40:39 +0000:
[Re: The stat file mechanism] I did some playing around with this to explore the actions and effects provoked by specifying "unusual" parameters, specifically for the "filedir" and "filename" parameters. Doing so, I realized that the "filedir" parameter isn't merely a single directory specification, but an array of such, akin to the "PATH" environment variable. Unfortunately, this can provoke some unexpected effects, especially in conjunction with Linux' (Unix') "HOME" directory designator, '~'. Thus, I inserted a preprocessing step to the "path" handling that replaces a leading '~' character with the HOME directory specification. This also works if just a single directory is given there. And I also made provision to the case that a directory specification does NOT end in a slash by adding one in that case. I append the resulting code to this message directly, because the modification is rather localized and does only pertain to the procedure named "tstatfile.writestat". As another point, I ALSO included a suggestion for a minor extension of this procedure, to allow for an empty filename to effect the use of the (base) name of the executable program, rather than to silently ignore the stat write request, as it does now. This is just a suggestion, and might be considered unneccessary, or it might be made optional by extending the set of option values by something like "sfo_useexename". This is the modified procedure: ---------------------------------------------------- procedure tstatfile.writestat(const stream: ttextstream = nil); var stream1: ttextstream; ar1: filenamearty; // fname1: filenamety; ///////////////////////////////////////////// i: integer; ///////////////////////////////////////////// bo1: boolean; begin if assigned(fonstatbeforewrite) then begin fonstatbeforewrite(self); end; if fnext <> nil then begin fnext.writestat(nil); end; stream1:= stream; ///////////////////////////////////////////// // Suggestion: if no filename specified, use executable base name - ??? // - optionally do so only if a NEWLY DEFINED option ("sfo_useexename" // or so) is set // - presumes fixed extension of "ConfExt = '.sta';" or such // -code: // IF (stream1 = nil) AND // not a memory stat file ?? // (fFileName = '') // use program name as a "last ressort" // THEN fFileName:= ExtractFilename (Argv [0])+ ConfExt; ///////////////////////////////////////////// if (stream1 = nil) and (filename <> '') then begin if sfo_memory in foptions then begin stream1:= memorystatstreams.open(ffilename,fm_create); end else begin if floadedfile = '' then begin unquotefilename(ffiledir,ar1); ///////////////////////////////////////////// FOR i:= 0 TO high (ar1) DO BEGIN {$IFDEF linux OR defined (freebsd) or defined (netbsd) OR defined openbsd() OR defined (Solaris)} // Or whatever is needed here... // On Linux, resolve tilde character and replace with home directory IF ar1 [i][1] = '~' THEN ar1 [i]:= GetEnvironmentVariable ('HOME')+ Copy (ar1 [i], 2, Length (ar1 [i])); {$ENDIF} // No directory separator after directory name? IF ar1 [i][Length (ar1 [i])] <> DirectorySeparator THEN ar1 [i]:= ar1 [i]+ DirectorySeparator; END; ///////////////////////////////////////////// if not findfile(ffilename,ar1,floadedfile) then begin floadedfile:= defaultfile(ar1); end; if (sfo_createpath in foptions) and not findfile(floadedfile) then begin createdirpath(msefileutils.filedir(floadedfile)); end; end; try if sfo_transaction in foptions then begin stream1:= ttextstream.createtransaction(floadedfile); end else begin stream1:= ttextstream.Create(floadedfile,fm_create); end; except floadedfile:= ''; raise; end; end; // stream1.encoding:= fencoding; end; if stream1 = nil then begin exit; end; try if (fcryptohandler <> nil) then begin stream1.cryptohandler:= fcryptohandler; end; awriter:= tstatwriter.create(stream1,fencoding); updateoptions(awriter); bo1:= false; try if (stream1.handle <> invalidfilehandle) and not stream1.usewritebuffer then begin bo1:= true; stream1.usewritebuffer:= true; end; internalwritestat; // if assigned(fonstatafterwrite) then begin // fonstatafterwrite(self); // end; finally freeandnil(awriter); if bo1 then begin stream1.usewritebuffer:= false; end; end; finally if stream = nil then begin stream1.Free; end else begin if (fcryptohandler <> nil) then begin stream1.cryptohandler:= nil; end; end; end; if assigned(fonstatafterwrite) then begin fonstatafterwrite(self); end; end; ---------------------------------------------------- Thank you for your consideration, and keep up the good work! -- (Weitergabe von Adressdaten, Telefonnummern u.ä. ohne Zustimmung nicht gestattet, ebenso Zusendung von Werbung oder ähnlichem) ----------------------------------------------------------- Mit freundlichen Grüßen, S. Schicktanz ----------------------------------------------------------- _______________________________________________ mseide-msegui-talk mailing list mseide-msegui-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk