diff --git a/src/BufferView.C b/src/BufferView.C index 7337937031..67bbf5d530 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -706,17 +706,17 @@ bool BufferView::dispatch(FuncRequest const & cmd) break; case LFUN_FILE_INSERT: - // FIXME: We don't know the encoding of filenames + // FIXME UNICODE menuInsertLyXFile(to_utf8(cmd.argument())); break; case LFUN_FILE_INSERT_ASCII_PARA: - // FIXME: We don't know the encoding of filenames + // FIXME UNICODE insertAsciiFile(this, to_utf8(cmd.argument()), true); break; case LFUN_FILE_INSERT_ASCII: - // FIXME: We don't know the encoding of filenames + // FIXME UNICODE insertAsciiFile(this, to_utf8(cmd.argument()), false); break; diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 979706645a..30c7c1b758 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -661,7 +661,7 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd) // insert file functions case LFUN_FILE_INSERT_ASCII_PARA: case LFUN_FILE_INSERT_ASCII: { - // FIXME: We don't know the encoding of filenames + // FIXME UNICODE string const tmpstr = getContentsOfAsciiFile(&cur.bv(), to_utf8(cmd.argument()), false); // FIXME: We don't know the encoding of the file if (!tmpstr.empty() && !insertAsciiString(cur.bv(), from_utf8(tmpstr), false)) diff --git a/src/lyx_cb.C b/src/lyx_cb.C index ffe3ce6ab6..5c307126bf 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -345,7 +345,7 @@ void insertAsciiFile(BufferView * bv, string const & f, bool asParagraph) // Insert ascii file (if filename is empty, prompt for one) string getContentsOfAsciiFile(BufferView * bv, string const & f, bool asParagraph) { - string fname = f; + FileName fname(f); if (fname.empty()) { FileDialog fileDlg(_("Select file to insert"), @@ -358,25 +358,25 @@ string getContentsOfAsciiFile(BufferView * bv, string const & f, bool asParagrap if (result.first == FileDialog::Later) return string(); - fname = to_utf8(result.second); + fname = FileName(makeAbsPath(to_utf8(result.second))); if (fname.empty()) return string(); } - if (!fs::is_readable(fname)) { + if (!fs::is_readable(fname.toFilesystemEncoding())) { docstring const error = from_ascii(strerror(errno)); - docstring const file = makeDisplayPath(fname, 50); + docstring const file = makeDisplayPath(fname.absFilename(), 50); docstring const text = bformat(_("Could not read the specified document\n" "%1$s\ndue to the error: %2$s"), file, error); Alert::error(_("Could not read file"), text); return string(); } - ifstream ifs(fname.c_str()); + ifstream ifs(fname.toFilesystemEncoding().c_str()); if (!ifs) { docstring const error = from_ascii(strerror(errno)); - docstring const file = makeDisplayPath(fname, 50); + docstring const file = makeDisplayPath(fname.absFilename(), 50); docstring const text = bformat(_("Could not open the specified document\n" "%1$s\ndue to the error: %2$s"), file, error); Alert::error(_("Could not open file"), text);