Forum > Unix

[Solved] Output of fpReadLink

(1/1)

Fred vS:
Hello.

With this:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program fpreadlink_test;  uses    baseunix;  var    pathexec : string;             begin      Fpreadlink('/proc/self/exe',@pathexec[0],high(pathexec));      writeln(pathexec);  end.
I get this:

--- Code: Text  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---~> ./fpreadlink_test home/fred/fpreadlink_test
OK, it works, also if a symlink -s was used.

But why is the first "/" before "home" missing in the output ? (Or I miss something.  :-[ )

Fre;D

Fred vS:
OK, found solution thanks to /fpcsrc/3.2.2/rtl/linux/system.pp and his SysInitExecPath procedure.

So this:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  Program fpreadlink_test;    uses      baseunix;    var      pathexec : shortstring;        i : integer;          begin      pathexec[0]:=#0;      i := Fpreadlink('/proc/self/exe',@pathexec[1],high(pathexec));      if (i>0) and (pathexec[1]='/') then pathexec[0]:=char(i);           writeln(pathexec);    end.
Gives this (with the "/" at begin):
 
--- Code: Text  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---~> ./fpreadlink_test/home/fred/fpreadlink_test
 :) ( and sorry for the noise)

Fre;D

Fred vS:
Even simpler:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Program fpreadlink_test;   uses     baseunix;   var     pathexec : shortstring;        begin    pathexec := Fpreadlink('/proc/self/exe');    writeln(pathexec);  end.

Navigation

[0] Message Index

Go to full version