allow user to open non-existent file again

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH-1_2_X@4831 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2002-08-01 19:28:57 +00:00
parent 04720fe8b8
commit 2f4db2b6cc
2 changed files with 20 additions and 6 deletions

View File

@ -1,3 +1,7 @@
2002-08-01 John Levon <levon@movementarian.org>
* lyxfunc.C: let user specify a non-existent file on open
2002-07-26 Juergen Vigna <jug@sad.it> 2002-07-26 Juergen Vigna <jug@sad.it>
* lyxfunc.C (dispatch):change LyXFind function call. * lyxfunc.C (dispatch):change LyXFind function call.

View File

@ -1887,16 +1887,26 @@ void LyXFunc::open(string const & fname)
// get absolute path of file and add ".lyx" to the filename if // get absolute path of file and add ".lyx" to the filename if
// necessary // necessary
string const fullpath = FileSearch(string(), filename, "lyx"); string const fullpath = FileSearch(string(), filename, "lyx");
if (fullpath.empty()) { if (!fullpath.empty()) {
Alert::alert(_("Error"), _("Could not find file"), filename); filename = fullpath;
return;
} }
filename = fullpath;
// loads document
string const disp_fn(MakeDisplayPath(filename)); string const disp_fn(MakeDisplayPath(filename));
// if the file doesn't exist, let the user create one
FileInfo const f(filename, true);
if (!f.exist()) {
if (!Alert::askQuestion(_("No such file"), disp_fn,
_("Start a new document with this filename ?"))) {
owner->message(_("Canceled"));
return;
}
// the user specifically chose this name. Believe them.
Buffer * buffer = bufferlist.newFile(filename, "", true);
owner->view()->buffer(buffer);
return;
}
ostringstream str; ostringstream str;
str << _("Opening document") << ' ' << disp_fn << "..."; str << _("Opening document") << ' ' << disp_fn << "...";