]> git.lyx.org Git - features.git/commitdiff
fix starting up which binary is really a symlink; make sure insetinclude file browser...
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 14 Jan 2002 23:31:23 +0000 (23:31 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 14 Jan 2002 23:31:23 +0000 (23:31 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3381 a592a061-630c-0410-9148-cb99ea01b6c8

25 files changed:
src/BufferView_pimpl.C
src/ChangeLog
src/LyXSendto.C
src/buffer.C
src/buffer.h
src/converter.C
src/exporter.C
src/frontends/ChangeLog
src/frontends/Liason.C
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlExternal.C
src/frontends/controllers/ControlGraphics.C
src/frontends/controllers/ControlInclude.C
src/frontends/controllers/helper_funcs.C
src/frontends/controllers/helper_funcs.h
src/insets/ChangeLog
src/insets/insetbib.C
src/insets/insetexternal.C
src/insets/insetgraphics.C
src/insets/insetgraphicsParams.C
src/insets/insetparent.C
src/lyx_cb.C
src/lyx_main.C
src/lyxfunc.C
src/vc-backend.C

index cf671b5216472648222c3c519c5acc404f43e424..11506b505e4237eaff2e99df4b8123146c689989 100644 (file)
@@ -1445,7 +1445,7 @@ void BufferView::Pimpl::MenuInsertLyXFile(string const & filen)
                string initpath = lyxrc.document_path;
 
                if (available()) {
-                       string const trypath = owner_->buffer()->filepath;
+                       string const trypath = owner_->buffer()->filePath();
                        // If directory is writeable, use this as default.
                        if (IsDirWriteable(trypath))
                                initpath = trypath;
index 05111ce2ffd64d23afddaab3af50e0c99e5a243c..fd700b29b4cf20fbbada454c5af3a37764a92730 100644 (file)
@@ -1,5 +1,32 @@
 2002-01-14  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
 
+       * lyx_cb.C (MenuWrite): buffer->fileName is guaranteed to be
+       absolute 
+
+       * vc-backend.C (most methods):
+       * exporter.C (Export): 
+       * converter.C (convert): 
+       (runLaTeX): 
+       * LyXSendto.C (SendtoApplyCB): 
+       * lyxfunc.C (dispatch): 
+       (menuNew): 
+       (open): 
+       (doImport): 
+       * lyx_cb.C (AutoSave): 
+       (InsertAsciiFile): 
+       * BufferView_pimpl.C (MenuInsertLyXFile): 
+       * buffer.C (runChktex): use Buffer::filePath().
+
+       * buffer.h: rename filename to filename_; rename filepath to
+       filepath_ and make it private
+       (filePath): new method
+
+       * buffer.C (writeFile): use fileName()
+       (getLatexName): 
+
+       * lyx_main.C (init): fix starting  of LyX when the binary is a
+       link from so,ewhere else.
+
        * minibuffer.C: include <cctype> for isprint
 
 2002-01-14  Angus Leeming  <a.leeming@ic.ac.uk>
index 5f672ac07bd0e4da087e725e2aaf06e06c7d0205..d457dc7fa11cf4e322c6015f24d3ca7a4fabe3fd 100644 (file)
@@ -80,7 +80,7 @@ void SendtoApplyCB(FL_OBJECT *, long)
     command = subst(command, "$$FName", fname);
     command += " &"; // execute in background
     // push directorypath, if necessary 
-    string path = OnlyPath(buffer->fileName());
+    string path = buffer->filePath();
     if (lyxrc.use_tempdir || !IsDirWriteable(path)){
         path = buffer->tmppath;
     }
index 19a4e42294d5623758712d156801824020358bff..c396b1ebad48504f473786ba631814c9454908a6 100644 (file)
@@ -151,11 +151,11 @@ extern int tex_code_break_column;
 Buffer::Buffer(string const & file, bool ronly)
        : paragraph(0), lyx_clean(true), bak_clean(true),
          unnamed(false), dep_clean(0), read_only(ronly),
-         filename(file), users(0)
+         filename_(file), users(0)
 {
        lyxerr[Debug::INFO] << "Buffer::Buffer()" << endl;
 //     filename = file;
-       filepath = OnlyPath(file);
+       filepath_ = OnlyPath(file);
 //     paragraph = 0;
 //     lyx_clean = true;
 //     bak_clean = true;
@@ -200,7 +200,7 @@ Buffer::~Buffer()
 
 string const Buffer::getLatexName(bool no_path) const
 {
-       string const name = ChangeExtension(MakeLatexName(filename), ".tex");
+       string const name = ChangeExtension(MakeLatexName(fileName()), ".tex");
        if (no_path)
                return OnlyFilename(name);
        else
@@ -273,9 +273,9 @@ void Buffer::resetAutosaveTimers() const
 
 void Buffer::setFileName(string const & newfile)
 {
-       filename = MakeAbsPath(newfile);
-       filepath = OnlyPath(filename);
-       setReadonly(IsFileWriteable(filename) == 0);
+       filename_ = MakeAbsPath(newfile);
+       filepath_ = OnlyPath(filename_);
+       setReadonly(IsFileWriteable(filename_) == 0);
        updateTitles();
 }
 
@@ -1702,7 +1702,7 @@ bool Buffer::writeFile(string const & fname, bool flag) const
        // warnings, only cerr.
        // Needed for autosave in background or panic save (Matthias 120496)
 
-       if (read_only && (fname == filename)) {
+       if (read_only && (fname == fileName())) {
                // Here we should come with a question if we should
                // perform the write anyway.
                if (flag)
@@ -3449,7 +3449,7 @@ int Buffer::runChktex()
 
        // get LaTeX-Filename
        string const name = getLatexName();
-       string path = OnlyPath(filename);
+       string path = filePath();
 
        string const org_path = path;
        if (lyxrc.use_tempdir || !IsDirWriteable(path)) {
@@ -3466,7 +3466,7 @@ int Buffer::runChktex()
        makeLaTeXFile(name, org_path, false);
 
        TeXErrors terr;
-       Chktex chktex(lyxrc.chktex_command, name, filepath);
+       Chktex chktex(lyxrc.chktex_command, name, filePath());
        int res = chktex.run(terr); // run chktex
 
        if (res == -1) {
index a85e04a4c151de18df0c2002f39a60320e7f53d6..d46e715ef9ce590fff28ac73a8a799bef6c11695 100644 (file)
@@ -212,9 +212,13 @@ public:
        /// Mark this buffer as dirty.
        void markDirty();
 
-       /// Returns the buffers filename.
+       /// Returns the buffer's filename. It is always an absolute path.
        string const & fileName() const;
 
+       /// Returns the the path where the buffer lives.
+       /// It is always an absolute path. 
+       string const & filePath() const;
+
        /** A transformed version of the file name, adequate for LaTeX.
            \param no_path optional if \c true then the path is stripped.
        */
@@ -312,9 +316,6 @@ public:
        /// Where to put temporary files.
        string tmppath;
 
-       /// The path to the document file.
-       string filepath;
-
        /** If we are writing a nice LaTeX file or not.
            While writing as LaTeX, tells whether we are
            doing a 'nice' LaTeX file */
@@ -339,7 +340,10 @@ private:
        bool read_only;
 
        /// name of the file the buffer is associated with.
-       string filename;
+       string filename_;
+
+       /// The path to the document file.
+       string filepath_;
 
        /// Format number of buffer
        int file_format;
@@ -529,7 +533,14 @@ void Buffer::markDirty()
 inline
 string const & Buffer::fileName() const
 {
-       return filename;
+       return filename_;
+}
+
+
+inline
+string const & Buffer::filePath() const
+{
+       return filepath_;
 }
 
 
index 0250142766ff8247a749af0b4e2f2ef2c8e01553..d9f0f72cf76732b9c9295912372f3a47d379278b 100644 (file)
@@ -649,7 +649,7 @@ bool Converters::convert(Buffer const * buffer,
                        Systemcalls one;
                        int res;
                        if (conv.original_dir && buffer) {
-                               Path p(buffer->filepath);
+                               Path p(buffer->filePath());
                                res = one.startscript(type, command);
                        } else
                                res = one.startscript(type, command);
@@ -851,7 +851,7 @@ bool Converters::runLaTeX(Buffer const * buffer, string const & command)
 
        // do the LaTex run(s)
        TeXErrors terr;
-       LaTeX latex(command, name, buffer->filepath);
+       LaTeX latex(command, name, buffer->filePath());
        int result = latex.run(terr,
                               bv ? bv->owner()->getLyXFunc() : 0);
        
index 68922a87fd3356fe773bca1f7d13c0d636ce884b..4a779ca0e3ced8c9667fa8bfb4b1c0fbeabe0c91 100644 (file)
@@ -71,12 +71,12 @@ bool Exporter::Export(Buffer * buffer, string const & format,
        // LaTeX backend
        else if (backend_format == format)
                buffer->makeLaTeXFile(filename, string(), true);
-       else if (contains(buffer->filepath, ' ')) {
+       else if (contains(buffer->filePath(), ' ')) {
                Alert::alert(_("Cannot run latex."),
                           _("The path to the lyx file cannot contain spaces."));
                return false;
        } else
-               buffer->makeLaTeXFile(filename, buffer->filepath, false);
+               buffer->makeLaTeXFile(filename, buffer->filePath(), false);
 
        string outfile_base = (put_in_tempdir)
                ? filename : buffer->getLatexName(false);
index 416ebdcd0bf00a2fb20b41500d3224334992913a..faf995cad87b56be9680aa6e87eaad565c6d5332 100644 (file)
@@ -1,3 +1,7 @@
+2002-01-14  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
+
+       * Liason.C (printBuffer): use Buffer::filePath
+
 2001-12-19  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
 
        * Timeout.h: 
index e54e8a9813d8bc98931d260877c43042c56df486..f1fe2c8dcbdf303a2a48b2b8175ea43f83579ba5 100644 (file)
@@ -106,7 +106,7 @@ bool printBuffer(Buffer * buffer, PrinterParams const & pp)
                return false;
 
        // Push directory path.
-       string path = OnlyPath(buffer->fileName());
+       string path = buffer->filePath();
        if (lyxrc.use_tempdir || !IsDirWriteable(path)) {
                path = buffer->tmppath;
        }
index 7d1567eb56e2274a6492a45a76f1b960e32bf198..c37de776d413041c0601de6aaba386dd9af0c3aa 100644 (file)
@@ -1,3 +1,10 @@
+2002-01-14  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
+
+       * ControlExternal.C (Browse): use Buffer::filePath; simplify (more
+       can be done)
+
+       * ControlGraphics.C (Browse): remove overzealous shortcut
+
 2002-01-14  Angus Leeming  <a.leeming@ic.ac.uk>
 
        * FormMinipage.C (apply, update): MinipageParams::width renamed
index 16ab959398f0e6f6b9697766bc5f898c241fc412..a38d8ade1cfddc5324417a608c448f3e66d3b333 100644 (file)
@@ -148,14 +148,17 @@ ExternalTemplate ControlExternal::getTemplate(int i) const
 
 string const ControlExternal::Browse(string const & input) const
 {
-       string buf  = MakeAbsPath(lv_.buffer()->fileName());
-       string buf2 = OnlyPath(buf);
+#ifdef WITH_WARNINGS
+#warning Candidate for using browseRelFile
+#endif
+       string buf;
+       string const bufpath = lv_.buffer()->filePath();
 
        if (!input.empty()) {
-               buf = MakeAbsPath(input, buf2);
+               buf = MakeAbsPath(input, bufpath);
                buf = OnlyPath(buf);
        } else {
-               buf = OnlyPath(lv_.buffer()->fileName());
+               buf = bufpath;
        }
     
        FileDialog fileDlg(&lv_,
@@ -185,7 +188,7 @@ string const ControlExternal::Browse(string const & input) const
 
                string p = result.second;
 
-               buf = MakeRelPath(p, buf2);
+               buf = MakeRelPath(p, bufpath);
                current_path = OnlyPath(p);
                once = 1;
                
index 6c13079749ced608abd41be664518a1e3c4139b5..b48630766c21fa559fe7d3452b1babe62ef8a7de 100644 (file)
@@ -77,7 +77,7 @@ extern string user_lyxdir;
 
 string const ControlGraphics::Browse(string const & in_name)
 {
-       string const title = N_("Graphics|#G#g");
+       string const title = N_("Graphics");
        // FIXME: currently we need the second '|' to prevent mis-interpretation 
        string const pattern = "*.(eps|png|jpeg|jpg|gif)|";
 
index b9775ab4a996c3ae622ea07a5d44d337f36d5415..a4796621b7a8bd10afcc299406c6659aefeea247 100644 (file)
@@ -24,9 +24,9 @@
 #include "LyXView.h"
 #include "lyxfunc.h"
 #include "gettext.h"
-
 #include "helper_funcs.h"
 #include "lyxrc.h"
+#include "support/filetools.h"
 
 using std::pair;
 using std::make_pair;
@@ -50,9 +50,8 @@ string const ControlInclude::Browse(string const & in_name, Type in_type)
 {
        string const title = N_("Select document to include");
 
-       string pattern;
-                  
        // input TeX, verbatim, or LyX file ?
+       string pattern;            
        switch (in_type) {
        case INPUT:
            pattern = _("*.tex| LaTeX Documents (*.tex)");
@@ -70,7 +69,9 @@ string const ControlInclude::Browse(string const & in_name, Type in_type)
        pair<string, string> dir1(N_("Documents|#o#O"),
                                  string(lyxrc.document_path));
 
-       return browseFile(&lv_, in_name, title, pattern, dir1);
+       string const docpath = OnlyPath(params().masterFilename_);
+       
+       return browseRelFile(&lv_, in_name, docpath, title, pattern, dir1);
 }
 
 
index d3fdf4435ebb63d9277bae475381ee141553aef2..ec3ef27b5e827a69ab875b51cbc945843237330c 100644 (file)
@@ -108,6 +108,24 @@ string const browseFile(LyXView * lv, string const & filename,
 }
 
 
+string const browseRelFile(LyXView * lv, string const & filename,
+                       string const & refpath,
+                       string const & title,
+                       string const & pattern, 
+                       pair<string,string> const & dir1,
+                       pair<string,string> const & dir2)
+{
+       string const fname = MakeAbsPath(filename, refpath);
+       
+       string const outname = browseFile(lv, fname, title, pattern, dir1);
+       string const reloutname = MakeRelPath(outname, refpath);
+       if(prefixIs(reloutname, "../"))
+               return outname;
+       else
+               return reloutname;
+}
+
+
 // sorry this is just a temporary hack we should include vspace.h! (Jug)
 extern const char * stringFromUnit(int);
 
index 095f8bb91a5715fc1d0fc97e28eac692b1d67c28..3631b692b059b09905e9e274f926a04e66d47706 100644 (file)
@@ -46,6 +46,20 @@ string const browseFile(LyXView *lv, string const & filename,
                        std::pair<string,string> const & dir2 = std::make_pair(string(), string()));
 
 
+/* Wrapper around browseFile which tries to provide a filename
+   relative to relpath.  If the relative path is of the form "foo.txt"
+   or "bar/foo.txt", then it is returned as relative. OTOH, if it is
+   of the form "../baz/foo.txt", an absolute path is returned. This is
+   intended to be useful for insets which encapsulate files/
+*/
+string const browseRelFile(LyXView *lv, string const & filename,
+                          string const & refpath,
+                          string const & title,
+                          string const & pattern, 
+                          std::pair<string,string> const & dir1 = std::make_pair(string(), string()),
+                          std::pair<string,string> const & dir2 = std::make_pair(string(), string()));
+
+
 /// Returns a vector of units that can be used to create a valid LaTeX length.
 std::vector<string> const getLatexUnits();
 
index af64bcd229d42c5bf4e75f0d9a9b2e01d705f8f7..3ecc8d642539388dd8aa41281aeef03dddc7c3d8 100644 (file)
@@ -1,3 +1,20 @@
+2002-01-14  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
+
+       * insetparent.C (InsetParent): 
+       * insetgraphicsParams.C (Write): 
+       (Read): 
+       * insetgraphics.C (prepareFile): 
+       (readFigInset): 
+       (docbook): 
+       * insetexternal.C (executeCommand): 
+       (doSubstitution): use Buffer::filePath
+
+       * insetbib.C (getFiles): add a #warning for Angus
+
+       * insetgraphics.C: Add a remark about how filenames should be
+       considered to be relative to buffer (but absolute is still allowed)
+       (draw): do not try to get status if lyxrc.use_gui is false
+
 2002-01-14  Angus Leeming  <a.leeming@ic.ac.uk>
 
        * inset.[Ch]:
index c82d4048003d80695880dd8305088183d07d79ef..933b3ddf916d78592b8efc67f2bc7d38f09c4d9f 100644 (file)
@@ -160,8 +160,8 @@ int InsetBibtex::latex(Buffer const * buffer, ostream & os,
        }
 
        if (!buffer->niceFile 
-           && IsFileReadable(MakeAbsPath(style, buffer->filepath) + ".bst")) {
-               style = MakeAbsPath(style, buffer->filepath);
+           && IsFileReadable(MakeAbsPath(style, buffer->filePath()) + ".bst")) {
+               style = MakeAbsPath(style, buffer->filePath());
        }
 
        if (!style.empty()) { // we want no \biblio...{}
@@ -198,8 +198,8 @@ int InsetBibtex::latex(Buffer const * buffer, ostream & os,
        // have a comma-separated list of bibliographies
        while (!adb.empty()) {
                if (!buffer->niceFile &&
-                   IsFileReadable(MakeAbsPath(adb, buffer->filepath)+".bib")) 
-                         adb = os::external_path(MakeAbsPath(adb, buffer->filepath));
+                   IsFileReadable(MakeAbsPath(adb, buffer->filePath())+".bib")) 
+                         adb = os::external_path(MakeAbsPath(adb, buffer->filePath()));
                db_out += adb;
                db_out += ',';
                db_in= split(db_in, adb,',');
@@ -213,7 +213,12 @@ int InsetBibtex::latex(Buffer const * buffer, ostream & os,
 vector<string> const InsetBibtex::getFiles(Buffer const &) const
 {
        // Doesn't appear to be used (Angus, 31 July 2001)
-       // Path p(buffer->filepath);
+       // Path p(buffer->filePath());
+#ifdef WITH_WARNINGS
+#warning Angus, do you now that this is not supposed to be used but to change path?
+// I would say this is needed to find bib files which are in the
+// document directory (JMarc 14/01/2002)
+#endif
 
        vector<string> vec;
 
index 735480991cc9c7671cbe9a4382ff3aa2172c4ed5..0349abad2bfc46bab2c6a12d49a2d5426dd3a071 100644 (file)
@@ -214,13 +214,11 @@ string const InsetExternal::getScreenLabel(Buffer const *) const
 void InsetExternal::executeCommand(string const & s,
                                   Buffer const * buffer) const
 {
-       string buf = MakeAbsPath(buffer->fileName());
-       string path = OnlyPath(buf);
-       Path p(path);
+       Path p(buffer->filePath());
        Systemcalls one;
        if (lyxerr.debugging()) {
                lyxerr << "Executing '" << s << "' in '"
-                      << path << "'" << endl;
+                      << buffer->filePath() << "'" << endl;
        }
        one.startscript(Systemcalls::Wait, s);
 }
@@ -231,9 +229,9 @@ string const InsetExternal::doSubstitution(Buffer const * buffer,
 {
        string result;
        string const basename = ChangeExtension(params_.filename, string());
-       string filepath = "";
+       string filepath;
        if (buffer && (!buffer->niceFile)) {
-               filepath = OnlyPath(MakeAbsPath(buffer->fileName()));
+               filepath = buffer->filePath();
        }
        result = subst(s, "$$FName", params_.filename);
        result = subst(result, "$$Basename", basename);
@@ -252,9 +250,7 @@ string const InsetExternal::doSubstitution(Buffer const * buffer,
                string contents;
                if (buffer) {
                        // Make sure we are in the directory of the buffer
-                       string const buf = MakeAbsPath(buffer->fileName());
-                       string const path = OnlyPath(buf);
-                       Path p(path);
+                       Path p(buffer->filePath());
                        contents = GetFileContents(file);
                } else {
                        contents = GetFileContents(file);
index 9b081b1fa32ef8f5896602eda5e27126ecf1463c..b2b1e46e9f6b592472d6bd960cfb37525a737849 100644 (file)
@@ -28,7 +28,15 @@ Known BUGS:
        We should probably use what the user asks to use... but when he chooses
        by the file dialog we normally get an absolute path and this may not be 
        what the user meant.
-
+       [Note that browseRelFile in helper_funcs.* provides a file name
+        which is relative if it is at reference path (here puffer path)
+        level or below, and an absolute path if the file name is not a
+        `natural' relative file name. In any case,
+            MakeAbsPath(filename, buf->filePath())
+        is guaranteed to provide the correct absolute path. This is what is
+        done know for include insets. Feel free to ask me -- JMarc
+       14/01/2002]
+       
        * If we are trying to create a file in a read-only directory and there
                are graphics that need converting, the converting will fail because
                it is done in-place, into the same directory as the original image.
@@ -69,15 +77,15 @@ TODO Extended features:
        to find it in the clipart, or in the same directory with the image.
     * Keep a tab on the image file, if it changes, update the lyx view.
        * The image choosing dialog could show thumbnails of the image formats
-               it knows of, thus selection based on the image instead of based on
-               filename.
+         it knows of, thus selection based on the image instead of based on
+         filename.
        * Add support for the 'picins' package.
        * Add support for the 'picinpar' package.
        * Improve support for 'subfigure' - Allow to set the various options
                that are possible.
-       * Add resizing by percentage of image size (50%, 150%) - usefull for two
-               images of different size to be resized where they both should have
-               the same scale compared to each other.
+       * Add resizing by percentage of image size (50%, 150%) -
+         usefull for two images of different size to be resized where
+         they both should have the same scale compared to each other.
  */
 
 /* NOTES:
@@ -301,8 +309,8 @@ void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
                
                // Get the image status, default to unknown error.
                GraphicsCacheItem::ImageStatus status = GraphicsCacheItem::UnknownError;
-               if (lyxrc.display_graphics != "no" &&
-                   params.display != InsetGraphicsParams::NONE &&
+               if (lyxrc.display_graphics != "no" && lyxrc.use_gui
+                   && params.display != InsetGraphicsParams::NONE &&
                    cacheHandle.get())
                        status = cacheHandle->getImageStatus();
                
@@ -433,7 +441,7 @@ void InsetGraphics::readFigInset(Buffer const * buf, LyXLex & lex)
                } else if (token == "file") {
                        if (lex.next()) {
                                string const name = lex.getString();
-                               string const path = OnlyPath(buf->fileName());
+                               string const path = buf->filePath();
                                params.filename = MakeAbsPath(name, path);
                        }
                } else if (token == "extra") {
@@ -668,7 +676,7 @@ InsetGraphics::prepareFile(Buffer const *buf) const
                //lyxerr << "temp = " << temp << "\n";
                //lyxerr << "outfile = " << outfile << endl;
        } else {
-               string const path = OnlyPath(buf->fileName());
+               string const path = buf->filePath();
                string const relname = MakeRelPath(params.filename, path);
                outfile = RemoveExtension(relname);
        }
@@ -764,7 +772,7 @@ int InsetGraphics::linuxdoc(Buffer const *, ostream &) const
 int InsetGraphics::docbook(Buffer const * buf, ostream & os) const
 {
        // Change the path to be relative to the main file.
-       string const buffer_dir = OnlyPath(buf->fileName());
+       string const buffer_dir = buf->filePath();
        string const filename = RemoveExtension(
                                   MakeRelPath(params.filename, buffer_dir));
 
index 846f28d84eb15595de1801e3293d9f580a2640cc..b99b52e0701ff783e51aaa2994ac6b8f878d2b6b 100644 (file)
@@ -233,7 +233,7 @@ void InsetGraphicsParams::Write(Buffer const * buf, ostream & os) const
        // If there is no filename, write nothing for it.
        if (! filename.empty()) {
                os << "filename "
-               << MakeRelPath(filename, OnlyPath(buf->fileName()))
+               << MakeRelPath(filename, buf->filePath())
                << '\n';
        }
 
@@ -291,7 +291,7 @@ bool InsetGraphicsParams::Read(Buffer const * buf, LyXLex & lex,
 
                if (!filename.empty()) {
                        // Make the filename with absolute directory.
-                       filename = MakeAbsPath(filename, OnlyPath(buf->fileName()));
+                       filename = MakeAbsPath(filename, buf->filePath());
                }
        } else if (token == "display") {
                lex.next();
index 56dcb26b51013c0f9c301f66a7d83e301c3616f3..7d79793adaae26389578dc78e9010bbae01220ad 100644 (file)
@@ -34,7 +34,7 @@ InsetParent::InsetParent(InsetCommandParams const & p, Buffer const & bf, bool)
        : InsetCommand(p)
 {
        string const fn = p.getContents();
-       setContents(MakeAbsPath(fn, OnlyPath(bf.fileName())));
+       setContents(MakeAbsPath(fn, bf.filePath()));
 }
 
 
index 43cfb02da6d044e26f222bbdb13d2996457c6db6..accc20cf9a0bad0e12bff2997cc9d5127a64501f 100644 (file)
@@ -143,10 +143,8 @@ bool MenuWrite(BufferView * bv, Buffer * buffer)
        XFlush(GUIRunTime::x11Display());
  
        if (!buffer->save()) {
-               string const fname = buffer->fileName();
-               string const s = MakeAbsPath(fname);
                if (Alert::askQuestion(_("Save failed. Rename and try again?"),
-                               MakeDisplayPath(s, 50),
+                               MakeDisplayPath(buffer->fileName(), 50),
                                _("(If not, document is not saved.)"))) {
                        return WriteAs(bv, buffer);
                }
@@ -325,7 +323,7 @@ void AutoSave(BufferView * bv)
        bv->owner()->message(_("Autosaving current document..."));
        
        // create autosave filename
-       string fname =  OnlyPath(bv->buffer()->fileName());
+       string fname =  bv->buffer()->filePath();
        fname += "#";
        fname += OnlyFilename(bv->buffer()->fileName());
        fname += "#";
@@ -420,7 +418,7 @@ void InsertAsciiFile(BufferView * bv, string const & f, bool asParagraph)
                FileDialog fileDlg(bv->owner(), _("Select file to insert"),
                        (asParagraph) ? LFUN_FILE_INSERT_ASCII_PARA : LFUN_FILE_INSERT_ASCII);
  
-               FileDialog::Result result = fileDlg.Select(bv->owner()->buffer()->filepath);
+               FileDialog::Result result = fileDlg.Select(bv->owner()->buffer()->filePath());
 
                if (result.first == FileDialog::Later)
                        return;
index dae669925425512ec5ce4001d353e2d94a709714..3b6e3a7ba62513a93945c3cf5b755c7ab81cf62d 100644 (file)
@@ -245,14 +245,15 @@ void LyX::init(bool gui)
 
        string binpath = os::binpath();
        string binname = os::binname();
-       string fullbinpath = binpath;
-
+       string fullbinname = MakeAbsPath(binname, binpath);
+       
        if (binpath.empty()) {
                lyxerr << _("Warning: could not determine path of binary.")
                       << "\n"
                       << _("If you have problems, try starting LyX with an absolute path.")
                       << endl;
        }
+       lyxerr[Debug::INIT] << "Name of binary: " << binname << endl;
        lyxerr[Debug::INIT] << "Path of binary: " << binpath << endl;
 
        //
@@ -286,30 +287,34 @@ void LyX::init(bool gui)
                searchpath += lyxdir + ';';
        }
 
-       // <path of binary>/TOP_SRCDIR/lib
-       build_lyxdir = MakeAbsPath("../lib", binpath);
-       if (!FileSearch(build_lyxdir, "lyxrc.defaults").empty()) {
-               searchpath += MakeAbsPath(AddPath(TOP_SRCDIR, "lib"),
-                                         binpath) + ';';
-               lyxerr[Debug::INIT] << "Checking whether LyX is run in "
-                       "place... yes" << endl;
-       } else {
-               lyxerr[Debug::INIT]
-                       << "Checking whether LyX is run in place... no"
-                       << endl;
-               build_lyxdir.erase();
+       string fullbinpath = binpath;
+       FileInfo file(fullbinname, true);
+       if (file.isLink()) {
+               lyxerr[Debug::INIT] << "binary is a link" << endl;
+               string link;
+               if (LyXReadLink(fullbinname, link)) {
+                       // Path of binary/../share/name of binary/
+                       searchpath += NormalizePath(AddPath(binpath,
+                                                           "../share/") 
+                                                   + OnlyFilename(binname));
+                       searchpath += ';';
+                       fullbinpath = link;
+                       binpath = MakeAbsPath(OnlyPath(fullbinpath));
+               }
        }
-
+       
         bool followlink;
        do {
-         // Path of binary/../share/name of binary/
+               // Path of binary/../share/name of binary/
                searchpath += NormalizePath(AddPath(binpath, "../share/") + 
                      OnlyFilename(binname)) + ';';
 
-         // Follow Symlinks
+               // Follow Symlinks
                FileInfo file(fullbinpath, true);
                followlink = file.isLink();
                if (followlink) {
+                       lyxerr << " directory " << fullbinpath
+                              << " is a link" << endl;
                        string link;
                        if (LyXReadLink(fullbinpath, link)) {
                                fullbinpath = link;
@@ -321,6 +326,20 @@ void LyX::init(bool gui)
                }
        } while (followlink);
 
+       // <path of binary>/TOP_SRCDIR/lib
+       build_lyxdir = MakeAbsPath("../lib", binpath);
+       if (!FileSearch(build_lyxdir, "lyxrc.defaults").empty()) {
+               searchpath += MakeAbsPath(AddPath(TOP_SRCDIR, "lib"),
+                                         binpath) + ';';
+               lyxerr[Debug::INIT] << "Checking whether LyX is run in "
+                       "place... yes" << endl;
+       } else {
+               lyxerr[Debug::INIT]
+                       << "Checking whether LyX is run in place... no"
+                       << endl;
+               build_lyxdir.erase();
+       }
+
        // Hardcoded dir
        searchpath += LYX_DIR;
 
index cdccd0689faf48e56f0a247acec12bd6227001a9..b65a5e647274dfb51da3180cc754e9578de475f1 100644 (file)
@@ -1508,7 +1508,7 @@ string const LyXFunc::dispatch(kb_action action, string argument)
        {
                string const filename =
                        MakeAbsPath(argument, 
-                                   OnlyPath(owner->buffer()->fileName()));
+                                   owner->buffer()->filePath());
                setMessage(N_("Opening child document ") +
                           MakeDisplayPath(filename) + "...");
                owner->view()->savePosition(0);
@@ -1647,7 +1647,7 @@ void LyXFunc::menuNew(bool fromTemplate)
        string initpath = lyxrc.document_path;
 
        if (owner->view()->available()) {
-               string const trypath = owner->buffer()->filepath;
+               string const trypath = owner->buffer()->filePath();
                // If directory is writeable, use this as default.
                if (IsDirWriteable(trypath))
                        initpath = trypath;
@@ -1773,7 +1773,7 @@ void LyXFunc::open(string const & fname)
        string initpath = lyxrc.document_path;
   
        if (owner->view()->available()) {
-               string const trypath = owner->buffer()->filepath;
+               string const trypath = owner->buffer()->filePath();
                // If directory is writeable, use this as default.
                if (IsDirWriteable(trypath))
                        initpath = trypath;
@@ -1850,7 +1850,7 @@ void LyXFunc::doImport(string const & argument)
                string initpath = lyxrc.document_path;
                
                if (owner->view()->available()) {
-                       string const trypath = owner->buffer()->filepath;
+                       string const trypath = owner->buffer()->filePath();
                        // If directory is writeable, use this as default.
                        if (IsDirWriteable(trypath))
                                initpath = trypath;
index 794c81fc4aec00630a3f1f1b519e73547c2d532e..c2d022344eb29f5ea48665ab146d1c54c01a7f28 100644 (file)
@@ -149,7 +149,7 @@ void RCS::registrer(string const & msg)
        cmd += "\" \"";
        cmd += OnlyFilename(owner_->fileName());
        cmd += "\"";
-       doVCCommand(cmd, owner_->filepath);
+       doVCCommand(cmd, owner_->filePath());
        owner_->getUser()->owner()->getLyXFunc()->dispatch(LFUN_MENURELOAD);
 }
 
@@ -157,7 +157,7 @@ void RCS::registrer(string const & msg)
 void RCS::checkIn(string const & msg)
 {
        doVCCommand("ci -q -u -m\"" + msg + "\" \""
-                   + OnlyFilename(owner_->fileName()) + "\"", owner_->filepath);
+                   + OnlyFilename(owner_->fileName()) + "\"", owner_->filePath());
        owner_->getUser()->owner()->getLyXFunc()->dispatch(LFUN_MENURELOAD);
 }
 
@@ -166,7 +166,7 @@ void RCS::checkOut()
 {
        owner_->markLyxClean();
        doVCCommand("co -q -l \""
-                   + OnlyFilename(owner_->fileName()) + "\"", owner_->filepath);
+                   + OnlyFilename(owner_->fileName()) + "\"", owner_->filePath());
        owner_->getUser()->owner()->getLyXFunc()->dispatch(LFUN_MENURELOAD);
 }
 
@@ -174,7 +174,7 @@ void RCS::checkOut()
 void RCS::revert()
 {
        doVCCommand("co -f -u" + version() + " \""
-                   + OnlyFilename(owner_->fileName()) + "\"", owner_->filepath);
+                   + OnlyFilename(owner_->fileName()) + "\"", owner_->filePath());
        // We ignore changes and just reload!
        owner_->markLyxClean();
        owner_->getUser()->owner()
@@ -187,14 +187,14 @@ void RCS::undoLast()
        lyxerr[Debug::LYXVC] << "LyXVC: undoLast" << endl;
        doVCCommand("rcs -o" + version() + " \""
                    + OnlyFilename(owner_->fileName()) + "\"",
-                   owner_->filepath);
+                   owner_->filePath());
 }
 
 
 void RCS::getLog(string const & tmpf)
 {
        doVCCommand("rlog \""
-                   + OnlyFilename(owner_->fileName()) + "\" > " + tmpf, owner_->filepath);
+                   + OnlyFilename(owner_->fileName()) + "\" > " + tmpf, owner_->filePath());
 }
 
 
@@ -279,7 +279,7 @@ void CVS::scanMaster()
 void CVS::registrer(string const & msg)
 {
        doVCCommand("cvs -q add -m \"" + msg + "\" \""
-                   + OnlyFilename(owner_->fileName()) + "\"", owner_->filepath);
+                   + OnlyFilename(owner_->fileName()) + "\"", owner_->filePath());
        owner_->getUser()->owner()->getLyXFunc()->dispatch(LFUN_MENURELOAD);
 }
 
@@ -288,7 +288,7 @@ void CVS::checkIn(string const & msg)
 {
        doVCCommand("cvs -q commit -m \"" + msg + "\" \""
                    + OnlyFilename(owner_->fileName()) + "\"",
-                   owner_->filepath);
+                   owner_->filePath());
        owner_->getUser()->owner()->getLyXFunc()->dispatch(LFUN_MENURELOAD);
 }
 
@@ -307,7 +307,7 @@ void CVS::revert()
        string const fil = OnlyFilename(owner_->fileName());
        
        doVCCommand("rm -f \"" + fil + "\"; cvs update \"" + fil + "\"",
-                   owner_->filepath);
+                   owner_->filePath());
        owner_->markLyxClean();
        owner_->getUser()->owner()
                ->getLyXFunc()->dispatch(LFUN_MENURELOAD);
@@ -327,5 +327,5 @@ void CVS::getLog(string const & tmpf)
 {
        doVCCommand("cvs log \""
                    + OnlyFilename(owner_->fileName()) + "\" > " + tmpf,
-                   owner_->filepath);
+                   owner_->filePath());
 }