mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 21:21:32 +00:00
more unicode filenames
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16171 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
c6e4985a07
commit
3314702bf1
@ -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;
|
||||
|
||||
|
@ -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))
|
||||
|
12
src/lyx_cb.C
12
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);
|
||||
|
Loading…
Reference in New Issue
Block a user