Georg Baum <[EMAIL PROTECTED]> writes: > And I found another problem with a fixed directory name like > "math-images": Things get mixed up if you export two documents in the > same directory. So even if the directory name is fixed for some reason it > should be unique per document, i. e. foo-math-images for foo.lyx or > something like that.
I thought about that. I changed the methods in Exporter to create non- existing directories (I thought first about your advice to add an "addExternalDirectory" method, but when I looked at the code this looked simpler). I also added a '$$n' parameter which gets replaced by the filename of the masterfile. The code in Exporter::Export now looks like this: if (!put_in_tempdir) { string const tmp_result_file = result_file; result_file = ChangeExtension(buffer->fileName(), formats.extension(format)); // We need to copy referenced files (e. g. included graphics // if format == "dvi") to the result dir. vector<ExportedFile> const files = runparams.exportdata->externalFiles(format); string const dest = OnlyPath(result_file); CopyStatus status = SUCCESS; for (vector<ExportedFile>::const_iterator it = files.begin(); it != files.end() && status != CANCEL; ++it) { string const fmt = formats.getFormatFromFile(it->sourceName); string const name = ChangeExtension(OnlyFilename(result_file), ""); string const exportName = subst(it->exportName, "$$n", name); string const path = MakeAbsPath(exportName, dest); string const dir = OnlyPath(path); if (! IsDirWriteable(dir) && ! createDirectory(dir,0777)) { Alert::error(_("Couldn't copy file"), bformat(_("Copying %1$s to %2$s failed."), MakeDisplayPath(path), MakeDisplayPath(dir))); status = CANCEL; } else { status = copyFile(fmt, it->sourceName, path, exportName, status == FORCE); } } if (status == CANCEL) { buffer->message(_("Document export cancelled.")); } else { // Finally copy the main file status = copyFile(format, tmp_result_file, result_file, result_file, status == FORCE); buffer->message(bformat(_("Document exported as %1$s" "to file `%2$s'"), formats.prettyName(format), MakeDisplayPath(result_file))); } } Questions: - Does that look ok? - Can I have "mkdir -p" functionality with createDirectory? - Does the '$$n' substitution need special protection? (the string containing the '$$n' will be hardcoded in mathhullinset.C) - I copied the Alert message verbatim from another place. What do I have to do if I introduce new internationalized strings? Any suggestions for a better error message? Ciao /Andreas