+
+ // If it's postscript, we always do eps.
+ // There are many suffixes that are actually EPS (ask Garst for example)
+ // so we detect if it's an EPS by looking in the file, if it is, we return
+ // the same suffix of the file so it won't be converted.
+ if (type == EPS)
+ return suffix;
+
+ return "eps";
+}
+
+} // Anon. namespace
+
+string const
+InsetGraphics::prepareFile(Buffer const *buf) const
+{
+
+ // do_convert = Do we need to convert the file?
+ // nice = Do we create a nice version?
+ // This is used when exporting the latex file only.
+ //
+ //
+ // if (!do_convert)
+ // return original filename
+ //
+ // if (!nice)
+ // convert_place = temp directory
+ // return new filename in temp directory
+ // else
+ // convert_place = original file directory
+ // return original filename without the extension
+ //
+
+ // Get the extension (format) of the original file.
+ string const extension = GetExtension(params.filename);
+ FileType type = classifyFileType(params.filename, extension);
+
+ // Are we creating a PDF or a PS file?
+ // (Should actually mean, are we usind latex or pdflatex).
+ string const image_target = decideOutputImageFormat(extension, type);
+
+ if (extension == image_target)
+ return params.filename;
+
+ string outfile;
+ if (!buf->niceFile) {
+ string const temp = AddName(buf->tmppath, params.filename);
+ outfile = RemoveExtension(temp);
+
+ //lyxerr << "buf::tmppath = " << buf->tmppath << "\n";
+ //lyxerr << "filename = " << params.filename << "\n";
+ //lyxerr << "temp = " << temp << "\n";
+ //lyxerr << "outfile = " << outfile << endl;
+ } else {
+ string const path = OnlyPath(buf->fileName());
+ string const relname = MakeRelPath(params.filename, path);
+ outfile = RemoveExtension(relname);