]> git.lyx.org Git - features.git/commitdiff
fix startup when lyx binary is a symlink
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 17 Jul 2002 21:43:06 +0000 (21:43 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 17 Jul 2002 21:43:06 +0000 (21:43 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4697 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/lyx_main.C
src/support/ChangeLog
src/support/filetools.C
src/support/filetools.h

index 46ec5100d59807443522119ed5de91abf006ad09..7b62ad35fed237d3ca5ecc39ef6e0cd5012ba886 100644 (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>
 
        * lyxfunc.h:
index 0ac6fa81d799a9684dc051db9a6cf640e0ddd6b6..3a0454692bd9b4bcc752c992887af3ae924cbe8b 100644 (file)
@@ -255,7 +255,7 @@ void LyX::init(bool gui)
        if (file.isLink()) {
                lyxerr[Debug::INIT] << "binary is a link" << endl;
                string link;
-               if (LyXReadLink(fullbinname, link)) {
+               if (LyXReadLink(fullbinname, link, true)) {
                        // Path of binary/../share/name of binary/
                        searchpath += NormalizePath(AddPath(binpath,
                                                            "../share/")
@@ -279,7 +279,7 @@ void LyX::init(bool gui)
                        lyxerr << " directory " << fullbinpath
                               << " is a link" << endl;
                        string link;
-                       if (LyXReadLink(fullbinpath, link)) {
+                       if (LyXReadLink(fullbinpath, link, true)) {
                                fullbinpath = link;
                                binpath = MakeAbsPath(OnlyPath(fullbinpath));
                        }
index eb4e94c52d4597ff0481a85e2c8a05ae7b6823ef..640e9b11503c08e9a15ee12d144687100055b2fc 100644 (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>
 
        * filetools.C (IsLyXFilename):
index 2e3ccac7b49a57cb37b032194ff674d111fe1401..d45d317612c24a996c67d2e7b4fc7f3d05c5822b 100644 (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
-       int const nRead = ::readlink(File.c_str(),
-                                    LinkBuffer, sizeof(LinkBuffer) - 1);
+       int const nRead = ::readlink(file.c_str(),
+                                    linkbuffer, sizeof(linkbuffer) - 1);
        if (nRead <= 0)
                return false;
-       LinkBuffer[nRead] = '\0'; // terminator
-       Link = LinkBuffer;
+       linkbuffer[nRead] = '\0'; // terminator
+       if (resolve)
+               link = MakeAbsPath(linkbuffer, OnlyPath(file));
+       else
+               link = linkbuffer;
        return true;
 }
 
index 5b89d84eb9f0e1a5eb1d3c4a21c32d6bc47fbcbe..bd15dfd3df6cb00172c08312a5b13a4f03020163 100644 (file)
@@ -195,9 +195,10 @@ string const GetFileContents(string const & fname);
 */
 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 */
-bool LyXReadLink(string const & file, string & Link);
+bool LyXReadLink(string const & file, string & link, bool resolve = false);
 
 /// Uses kpsewhich to find tex files
 string const findtexfile(string const & fil, string const & format);