fix startup when lyx binary is a symlink

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4697 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2002-07-17 21:43:06 +00:00
parent acb4e0a1d3
commit 0e94da770a
5 changed files with 23 additions and 10 deletions

View File

@ -1,3 +1,7 @@
2002-07-17 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* lyx_main.C (init): make sure to read symlinks as absolute paths
2002-07-17 John Levon <moz@compsoc.man.ac.uk> 2002-07-17 John Levon <moz@compsoc.man.ac.uk>
* lyxfunc.h: * lyxfunc.h:

View File

@ -255,7 +255,7 @@ void LyX::init(bool gui)
if (file.isLink()) { if (file.isLink()) {
lyxerr[Debug::INIT] << "binary is a link" << endl; lyxerr[Debug::INIT] << "binary is a link" << endl;
string link; string link;
if (LyXReadLink(fullbinname, link)) { if (LyXReadLink(fullbinname, link, true)) {
// Path of binary/../share/name of binary/ // Path of binary/../share/name of binary/
searchpath += NormalizePath(AddPath(binpath, searchpath += NormalizePath(AddPath(binpath,
"../share/") "../share/")
@ -279,7 +279,7 @@ void LyX::init(bool gui)
lyxerr << " directory " << fullbinpath lyxerr << " directory " << fullbinpath
<< " is a link" << endl; << " is a link" << endl;
string link; string link;
if (LyXReadLink(fullbinpath, link)) { if (LyXReadLink(fullbinpath, link, true)) {
fullbinpath = link; fullbinpath = link;
binpath = MakeAbsPath(OnlyPath(fullbinpath)); binpath = MakeAbsPath(OnlyPath(fullbinpath));
} }

View File

@ -1,3 +1,8 @@
2002-07-17 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* filetools.C (LyXReadLink): add bool 'resolve' to return link
contents as an absolute path
2002-07-15 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr> 2002-07-15 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* filetools.C (IsLyXFilename): * filetools.C (IsLyXFilename):

View File

@ -1269,16 +1269,19 @@ MakeDisplayPath (string const & path, unsigned int threshold)
} }
bool LyXReadLink(string const & File, string & Link) bool LyXReadLink(string const & file, string & link, bool resolve)
{ {
char LinkBuffer[512]; char linkbuffer[512];
// Should be PATH_MAX but that needs autconf support // Should be PATH_MAX but that needs autconf support
int const nRead = ::readlink(File.c_str(), int const nRead = ::readlink(file.c_str(),
LinkBuffer, sizeof(LinkBuffer) - 1); linkbuffer, sizeof(linkbuffer) - 1);
if (nRead <= 0) if (nRead <= 0)
return false; return false;
LinkBuffer[nRead] = '\0'; // terminator linkbuffer[nRead] = '\0'; // terminator
Link = LinkBuffer; if (resolve)
link = MakeAbsPath(linkbuffer, OnlyPath(file));
else
link = linkbuffer;
return true; return true;
} }

View File

@ -195,9 +195,10 @@ string const GetFileContents(string const & fname);
*/ */
string const ReplaceEnvironmentPath(string const & path); string const ReplaceEnvironmentPath(string const & path);
/* Set Link to the path file points to as a symbolic link. /* Set \c link to the path \c file points to as a symbolic link.
If \c resolve is true, then \c link is an absolute path
Returns true if successful */ Returns true if successful */
bool LyXReadLink(string const & file, string & Link); bool LyXReadLink(string const & file, string & link, bool resolve = false);
/// Uses kpsewhich to find tex files /// Uses kpsewhich to find tex files
string const findtexfile(string const & fil, string const & format); string const findtexfile(string const & fil, string const & format);