It strikes me that we bend ourselves into all sorts of contortions when it 
comes up file names because we store a single string and then try and guess 
how to use it in different places.

I think that are requirements are no more complex than this:

class FileName {
        FileName(string const & abs_filename, bool output_relative)
                : absolute_filename_(abs_filename),
                  output_relative_to_buffer_path_(output_relative)
        {
                if (!absolute_filename_.empty())
                        lyx::Assert(AbsolutePath(absolute_filename_));
        }

        /** Signals intent. The file name was stored in the LyX file with
            a relative path. It should be output in the same way. */
        bool outputRelative() const { return output_relative_to_buffer_path_; }

        string const & absFilename() const { return absolute_filename_; }
        string const relFilename(string const & base_path) {
                lyx::Assert(AbsolutePath(AbsolutePath));
                return MakeRelPath(absolute_filename_, base_path);
        }
private:
        string absolute_filename_;
        bool output_relative_to_buffer_path_;
};

Opinions?

-- 
Angus

Reply via email to