src/LColor.C
src/LaTeX.C
src/MenuBackend.C
-src/ParagraphParameters.C
src/buffer.C
src/buffer_funcs.C
src/bufferlist.C
src/bufferparams.C
-src/bufferview_funcs.C
src/converter.C
src/debug.C
src/exporter.C
src/paragraph_funcs.C
src/rowpainter.C
src/support/globbing.C
-src/support/path_defines.C
-src/tex2lyx/lengthcommon.C
src/text.C
src/text2.C
src/text3.C
+2004-02-21 Georg Baum <Georg.Baum@post.rwth-aachen.de>
+
+ * lyxrc.C, buffer.C, exporter.C: use always a temp dir, ignore
+ use_tempdir in preferences
+ * buffer.C (readFile), lyxvc.C (getLogFile): check success of
+ tempfile creation
+ * lyx_main.C: ensure that tempdir is valid
+ * lyxlex.h: correct typo
+ * buffer.[Ch] (isMultiLingual), (isUnnamed): make const
+ * paragraph.[Ch] (isMultiLingual): make const
+ * cursor.[Ch] (openable): make const
+
2004-02-20 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* text3.C: fixed LFUN_QUOTE and add lfun arguments single/double.
#include "lyxtext.h"
#include "lyxrc.h"
#include "lyxvc.h"
+#include "lyx_main.h"
#include "messages.h"
#include "output.h"
#include "output_docbook.h"
using lyx::support::bformat;
using lyx::support::ChangeExtension;
using lyx::support::cmd_ret;
-using lyx::support::CreateBufferTmpDir;
+using lyx::support::createBufferTmpDir;
using lyx::support::destroyDir;
using lyx::support::FileInfo;
using lyx::support::FileInfo;
text(0, 0)
{
lyxvc.buffer(&parent);
- if (readonly_ || lyxrc.use_tempdir)
- temppath = CreateBufferTmpDir();
+ temppath = createBufferTmpDir();
+ // FIXME: And now do something if temppath == string(), because we
+ // assume from now on that temppath points to a valid temp dir.
+ // See http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg67406.html
}
if (filename.empty())
return make_pair(Buffer::latexlog, string());
- string path = OnlyPath(filename);
-
- if (lyxrc.use_tempdir || !IsDirWriteable(path))
- path = temppath();
+ string const path = temppath();
string const fname = AddName(path,
OnlyFilename(ChangeExtension(filename,
filename));
} else if (file_format < LYX_FORMAT) {
string const tmpfile = tempName();
+ if (tmpfile.empty()) {
+ Alert::error(_("Conversion failed"),
+ bformat(_("%1$s is from an earlier"
+ " version of LyX, but a temporary"
+ " file for converting it could"
+ " not be created."),
+ filename));
+ return false;
+ }
string command = LibFileSearch("lyx2lyx", "lyx2lyx");
if (command.empty()) {
Alert::error(_("Conversion script not found"),
void Buffer::makeLinuxDocFile(string const & fname,
OutputParams const & runparams,
- bool body_only )
+ bool body_only)
{
ofstream ofs;
if (!openFileWrite(ofs, fname))
// get LaTeX-Filename
string const name = getLatexName();
- string path = filePath();
-
- string const org_path = path;
- if (lyxrc.use_tempdir || !IsDirWriteable(path)) {
- path = temppath();
- }
+ string const path = temppath();
+ string const org_path = filePath();
Path p(path); // path to LaTeX file
message(_("Running chktex..."));
}
-bool Buffer::isMultiLingual()
+bool Buffer::isMultiLingual() const
{
- ParIterator end = par_iterator_end();
- for (ParIterator it = par_iterator_begin(); it != end; ++it)
+ ParConstIterator end = par_iterator_end();
+ for (ParConstIterator it = par_iterator_begin(); it != end; ++it)
if (it->isMultiLingual(params()))
return true;
}
-bool Buffer::isUnnamed()
+bool Buffer::isUnnamed() const
{
return pimpl_->unnamed;
}
void setUnnamed(bool flag = true);
///
- bool isUnnamed();
+ bool isUnnamed() const;
/// Mark this buffer as dirty.
void markDirty();
void updateDocLang(Language const * nlang);
///
- bool isMultiLingual();
+ bool isMultiLingual() const;
/// Does this mean that this is buffer local?
limited_stack<Undo> & undostack();
}
-bool LCursor::openable(MathAtom const & t)
+bool LCursor::openable(MathAtom const & t) const
{
if (!t->isActive())
return false;
/// where in the curent cell does the macro name start?
int macroNamePos();
/// can we enter the inset?
- bool openable(MathAtom const &);
+ bool openable(MathAtom const &) const;
};
#endif // LYXCURSOR_H
backend_format = format;
string filename = buffer->getLatexName(false);
- if (!buffer->temppath().empty())
- filename = AddName(buffer->temppath(), filename);
+ filename = AddName(buffer->temppath(), filename);
filename = ChangeExtension(filename,
formats.extension(backend_format));
+2004-02-21 Georg Baum <Georg.Baum@post.rwth-aachen.de>
+
+ * ControlPrint.C, ControlSendto.C: use always a temp dir
+ * ControlSendto.C: check return value of buffer()->writeFile()
+
2004-02-01 Lars Gullik Bjonnes <larsbj@gullik.net>
* biblio.C (parseBibTeX): "=" -> '='
}
// Push directory path.
- string path = buffer()->filePath();
- if (lyxrc.use_tempdir || !IsDirWriteable(path)) {
- path = buffer()->temppath();
- }
+ string const path = buffer()->temppath();
Path p(path);
// there are three cases here:
if (format_->name() == "lyx") {
filename = ChangeExtension(buffer()->getLatexName(false),
format_->extension());
- if (!buffer()->temppath().empty())
- filename = AddName(buffer()->temppath(), filename);
+ filename = AddName(buffer()->temppath(), filename);
- buffer()->writeFile(filename);
+ if (!buffer()->writeFile(filename))
+ return;
} else {
Exporter::Export(buffer(), format_->name(), true, filename);
+2004-02-21 Georg Baum <Georg.Baum@post.rwth-aachen.de>
+
+ * QPrefs.C, QPrefsDialog.C, ui/QPrefPathsModule.ui: remove
+ use_tempdir
+
2004-02-20 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* QDocument.C:
rc.document_path = fromqstr(pathsmod->workingDirED->text());
rc.template_path = fromqstr(pathsmod->templateDirED->text());
rc.backupdir_path = fromqstr(pathsmod->backupDirED->text());
- rc.use_tempdir = pathsmod->tempDirCB->isChecked();
rc.tempdir_path = fromqstr(pathsmod->tempDirED->text());
// FIXME: should be a checkbox only
rc.lyxpipes = fromqstr(pathsmod->lyxserverDirED->text());
pathsmod->workingDirED->setText(toqstr(rc.document_path));
pathsmod->templateDirED->setText(toqstr(rc.template_path));
pathsmod->backupDirED->setText(toqstr(rc.backupdir_path));
- pathsmod->tempDirCB->setChecked(rc.use_tempdir);
pathsmod->tempDirED->setText(toqstr(rc.tempdir_path));
// FIXME: should be a checkbox only
pathsmod->lyxserverDirED->setText(toqstr(rc.lyxpipes));
connect(pathsModule->workingDirED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
connect(pathsModule->templateDirED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
connect(pathsModule->backupDirED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
- connect(pathsModule->tempDirCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
connect(pathsModule->tempDirED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
connect(pathsModule->lyxserverDirED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
connect(spellcheckerModule->spellCommandCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
</property>
</widget>
<widget row="4" column="0" >
- <class>QCheckBox</class>
+ <class>QLabel</class>
<property stdset="1">
<name>name</name>
- <cstring>tempDirCB</cstring>
+ <cstring>tempDirLA</cstring>
</property>
<property stdset="1">
<name>text</name>
- <string>&Use temporary directory</string>
+ <string>&Temporary directory:</string>
+ </property>
+ <property>
+ <name>buddy</name>
+ <cstring>tempDirED</cstring>
</property>
</widget>
<widget row="3" column="2" >
</spacer>
</vbox>
</widget>
-<connections>
- <connection>
- <sender>tempDirCB</sender>
- <signal>toggled(bool)</signal>
- <receiver>tempDirED</receiver>
- <slot>setEnabled(bool)</slot>
- </connection>
- <connection>
- <sender>tempDirCB</sender>
- <signal>toggled(bool)</signal>
- <receiver>tempDirPB</receiver>
- <slot>setEnabled(bool)</slot>
- </connection>
-</connections>
<tabstops>
<tabstop>workingDirED</tabstop>
<tabstop>workingDirPB</tabstop>
<tabstop>backupDirPB</tabstop>
<tabstop>lyxserverDirED</tabstop>
<tabstop>lyxserverDirPB</tabstop>
- <tabstop>tempDirCB</tabstop>
<tabstop>tempDirED</tabstop>
<tabstop>tempDirPB</tabstop>
</tabstops>
+2004-02-21 Georg Baum <Georg.Baum@post.rwth-aachen.de>
+
+ * FormPreferences.C, forms/form_preferences.fd: remove use_tempdir
+
2004-02-20 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* FormDocument.C:
{
rc.document_path = fl_get_input(dialog_->input_default_path);
rc.template_path = fl_get_input(dialog_->input_template_path);
+ rc.tempdir_path = fl_get_input(dialog_->input_temp_dir);
- int button = fl_get_button(dialog_->check_use_temp_dir);
- string str = fl_get_input(dialog_->input_temp_dir);
- if (!button)
- str.erase();
-
- rc.use_tempdir = button;
- rc.tempdir_path = str;
-
- button = fl_get_button(dialog_->check_last_files);
- str = fl_get_input(dialog_->input_lastfiles);
+ int button = fl_get_button(dialog_->check_last_files);
+ string str = fl_get_input(dialog_->input_lastfiles);
if (!button) str.erase();
rc.check_lastfiles = button;
setPrehandler(dialog_->input_backup_path);
setPrehandler(dialog_->input_serverpipe);
setPrehandler(dialog_->input_temp_dir);
- setPrehandler(dialog_->check_use_temp_dir);
}
return LyXRC::getDescription(LyXRC::RC_DOCUMENTPATH);
if (ob == dialog_->input_template_path)
return LyXRC::getDescription(LyXRC::RC_TEMPLATEPATH);
- if (ob == dialog_->check_use_temp_dir)
- return LyXRC::getDescription(LyXRC::RC_USETEMPDIR);
if (ob == dialog_->input_temp_dir)
return LyXRC::getDescription(LyXRC::RC_TEMPDIRPATH);
if (ob == dialog_->check_last_files)
// !ob if function is called from Paths::update() to de/activate
// objects,
// otherwise the function is called by an xforms CB via input().
- if (!ob || ob == dialog_->check_use_temp_dir) {
- bool const enable = fl_get_button(dialog_->check_use_temp_dir);
- setEnabled(dialog_->input_temp_dir, enable);
- }
-
if (!ob || ob == dialog_->check_last_files) {
bool const enable = fl_get_button(dialog_->check_last_files);
setEnabled(dialog_->input_lastfiles, enable);
rc.make_backup);
fl_set_input(dialog_->input_backup_path, str.c_str());
- str.erase();
- if (rc.use_tempdir)
- str = rc.tempdir_path;
-
- fl_set_button(dialog_->check_use_temp_dir,
- rc.use_tempdir);
- fl_set_input(dialog_->input_temp_dir, str.c_str());
+ fl_set_input(dialog_->input_temp_dir, rc.tempdir_path.c_str());
str.erase();
if (rc.check_lastfiles)
Name: form_preferences_paths
Width: 450
Height: 350
-Number of Objects: 17
+Number of Objects: 16
--------------------
class: FL_BOX
callback: C_FormBaseInputCB
argument: 0
---------------------
-class: FL_CHECKBUTTON
-type: PUSH_BUTTON
-box: 140 80 30 30
-boxtype: FL_NO_BOX
-colors: FL_COL1 FL_YELLOW
-alignment: FL_ALIGN_LEFT
-style: FL_NORMAL_STYLE
-size: FL_NORMAL_SIZE
-lcol: FL_BLACK
-label: Temp dir:|#d
-shortcut:
-resize: FL_RESIZE_ALL
-gravity: FL_NoGravity FL_NoGravity
-name: check_use_temp_dir
-callback: C_FormBaseInputCB
-argument: 0
- value: 1
-
--------------------
class: FL_INPUT
type: NORMAL_INPUT
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
-label:
+label: Temp dir:|#d
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
+2004-02-21 Georg Baum <Georg.Baum@post.rwth-aachen.de>
+
+ * GraphicsCacheItem.C (convertToDisplayFormat): unzip zipped files
+ to a temporary file
+ * PreviewLoader.C: use always a temp dir
+ * PreviewLoader.C: check successfull creation of LaTeX file
+
2004-01-31 Lars Gullik Bjonnes <larsbj@gullik.net>
* PreviewLoader.C (FindFirst): inherit from std::unary_function
using support::tempName;
using support::unlink;
using support::unzipFile;
+using support::unzippedFileName;
using support::zippedFile;
using std::endl;
}
// Make a local copy in case we unzip it
- string const filename = zippedFile(filename_) ?
- unzipFile(filename_) : filename_;
+ string filename;
+ if ((zipped_ = zippedFile(filename_))) {
+ unzipped_filename_ = tempName(string(), filename_);
+ if (unzipped_filename_.empty()) {
+ setStatus(ErrorConverting);
+ lyxerr[Debug::GRAPHICS]
+ << "\tCould not create temporary file." << endl;
+ return;
+ }
+ filename = unzipFile(filename_, unzipped_filename_);
+ } else
+ filename = filename_;
+
string const displayed_filename = MakeDisplayPath(filename_);
lyxerr[Debug::GRAPHICS] << "[GrahicsCacheItem::convertToDisplayFormat]\n"
<< "\tAttempting to convert image file: " << filename
remove_loaded_file_ = true;
// Remove the temp file, we only want the name...
+ // FIXME: This is unsafe!
unlink(to_file_base);
// Connect a signal to this->imageConverted and pass this signal to
lyxerr[Debug::GRAPHICS] << "PreviewLoader::startLoading()" << endl;
// As used by the LaTeX file and by the resulting image files
- string const directory = buffer_.temppath().empty() ?
- buffer_.filePath() : buffer_.temppath();
+ string const directory = buffer_.temppath();
string const filename_base(unique_filename(directory));
string const latexfile = filename_base + ".tex";
ofstream of(latexfile.c_str());
+ if (!of) {
+ lyxerr[Debug::GRAPHICS] << "PreviewLoader::startLoading()\n"
+ << "Unable to create LaTeX file\n"
+ << latexfile << endl;
+ return;
+ }
of << "\\batchmode\n";
dumpPreamble(of);
of << "\n\\begin{document}\n";
+2004-02-21 Georg Baum <Georg.Baum@post.rwth-aachen.de>
+
+ * insetexternal.C, insetgraphics.C, insetinclude.C: use always a
+ temp dir
+ * insetinclude.C (latex): show a GUI warning if textclasses don't
+ match
+ * insetinclude.C: use mangledFilename() for temp files
+ * insetgraphics.C (readInsetGraphics): remove version check, since
+ the graphics inset has no own fileformat number anymore
+
2004-02-20 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* insetquotes.[Ch]: added new member that allows direct access
TempName::TempName()
{
tempname_ = support::tempName(string(), "lyxext");
+ // FIXME: This is unsafe
support::unlink(tempname_);
// must have an extension for the converter code to work correctly.
tempname_ += ".tmp";
// run through the LaTeX compiler.
// If we're running through the LaTeX compiler, we should write the
// generated files in the bufer's temporary directory.
- bool const external_in_tmpdir =
- lyxrc.use_tempdir && !buf.temppath().empty() && !runparams.nice;
+ bool const external_in_tmpdir = !runparams.nice;
// If the template has specified a PDFLaTeX output, then we try and
// use that.
/* NOTES:
* Fileformat:
- * Current version is 1 (inset file format version), when changing it
- * it should be changed in the Write() function when writing in one place
- * and when reading one should change the version check and the error message.
* The filename is kept in the lyx file in a relative way, so as to allow
* moving the document file and its images with no problem.
*
continue;
} else if (token == "\\end_inset") {
finished = true;
- } else if (token == "FormatVersion") {
- lex.next();
- int version = lex.getInteger();
- if (version > VersionNumber)
- lyxerr
- << "This document was created with a newer Graphics widget"
- ", You should use a newer version of LyX to read this"
- " file."
- << endl;
- // TODO: Possibly open up a dialog?
- }
- else {
+ } else {
if (!params_.Read(lex, token, bufpath))
lyxerr << "Unknown token, " << token << ", skipping."
<< std::endl;
lyxerr[Debug::GRAPHICS]
<< "\t we have: from " << from << " to " << to << '\n';
- if (from == to && !lyxrc.use_tempdir)
- return stripExtensionIfPossible(orig_file, to);
-
// We're going to be running the exported buffer through the LaTeX
// compiler, so must ensure that LaTeX can cope with the graphics
// file format.
<< "\tthe orig file is: " << orig_file << endl;
bool conversion_needed = true;
- if (lyxrc.use_tempdir) {
- CopyStatus status;
- boost::tie(status, temp_file) =
+ CopyStatus status;
+ boost::tie(status, temp_file) =
copyToDirIfNeeded(orig_file, buf.temppath());
- if (status == FAILURE)
- return orig_file;
- else if (status == IDENTICAL_CONTENTS)
- conversion_needed = false;
- }
+ if (status == FAILURE)
+ return orig_file;
+ else if (status == IDENTICAL_CONTENTS)
+ conversion_needed = false;
if (from == to)
return stripExtensionIfPossible(temp_file, to);
<< "\tto_file_base = " << to_file_base << '\n'
<< "\t from " << from << " to " << to << '\n';
- // if no special converter defined, than we take the default one
+ // if no special converter defined, then we take the default one
// from ImageMagic: convert from:inname.from to:outname.to
if (!converters.convert(&buf, temp_file, to_file_base, from, to)) {
string const command =
#include "metricsinfo.h"
#include "outputparams.h"
+#include "frontends/Alert.h"
#include "frontends/LyXView.h"
#include "frontends/Painter.h"
#include "insets/render_preview.h"
#include "support/FileInfo.h"
+#include "support/filename.h"
#include "support/filetools.h"
#include "support/lstrings.h" // contains
#include "support/tostr.h"
#include "support/std_sstream.h"
using lyx::support::AddName;
+using lyx::support::bformat;
using lyx::support::ChangeExtension;
using lyx::support::contains;
using lyx::support::FileInfo;
+using lyx::support::FileName;
using lyx::support::GetFileContents;
using lyx::support::IsFileReadable;
using lyx::support::IsLyXFilename;
if (loadIfNeeded(buffer, params_)) {
Buffer * tmp = bufferlist.getBuffer(included_file);
- // FIXME: this should be a GUI warning
if (tmp->params().textclass != buffer.params().textclass) {
- lyxerr << "WARNING: Included file `"
- << MakeDisplayPath(included_file)
- << "' has textclass `"
- << tmp->params().getLyXTextClass().name()
- << "' while parent file has textclass `"
- << buffer.params().getLyXTextClass().name()
- << "'." << endl;
+ string text = bformat(_("Included file `%1$s'\n"
+ "has textclass `%2$s'\n"
+ "while parent file has textclass `%3$s'."),
+ MakeDisplayPath(included_file),
+ tmp->params().getLyXTextClass().name(),
+ buffer.params().getLyXTextClass().name());
+ Alert::warning(_("Different textclasses"), text);
//return 0;
}
// write it to a file (so far the complete file)
string writefile = ChangeExtension(included_file, ".tex");
- if (!buffer.temppath().empty() && !runparams.nice) {
- incfile = subst(incfile, '/','@');
-#ifdef __EMX__
- incfile = subst(incfile, ':', '$');
-#endif
- writefile = AddName(buffer.temppath(), incfile);
- } else
- writefile = included_file;
- writefile = ChangeExtension(writefile, ".tex");
+ if (!runparams.nice) {
+ incfile = FileName(writefile).mangledFilename();
+ writefile = MakeAbsPath(incfile, buffer.temppath());
+ }
+
lyxerr[Debug::LATEX] << "incfile:" << incfile << endl;
lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
Buffer * tmp = bufferlist.getBuffer(included_file);
// write it to a file (so far the complete file)
- string writefile = ChangeExtension(included_file, ".sgml");
- if (!buffer.temppath().empty() && !runparams.nice) {
- incfile = subst(incfile, '/','@');
- writefile = AddName(buffer.temppath(), incfile);
- } else
+ string writefile;
+ if (IsLyXFilename(included_file))
+ writefile = ChangeExtension(included_file, ".sgml");
+ else
writefile = included_file;
- if (IsLyXFilename(included_file))
- writefile = ChangeExtension(writefile, ".sgml");
+ if (!runparams.nice) {
+ incfile = FileName(writefile).mangledFilename();
+ writefile = MakeAbsPath(incfile, buffer.temppath());
+ }
lyxerr[Debug::LATEX] << "incfile:" << incfile << endl;
lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
Buffer * tmp = bufferlist.getBuffer(included_file);
// write it to a file (so far the complete file)
- string writefile = ChangeExtension(included_file, ".sgml");
- if (!buffer.temppath().empty() && !runparams.nice) {
- incfile = subst(incfile, '/','@');
- writefile = AddName(buffer.temppath(), incfile);
- } else
- writefile = included_file;
+ string writefile;
if (IsLyXFilename(included_file))
- writefile = ChangeExtension(writefile, ".sgml");
+ writefile = ChangeExtension(included_file, ".sgml");
+ else
+ writefile = included_file;
+
+ if (!runparams.nice) {
+ incfile = FileName(writefile).mangledFilename();
+ writefile = MakeAbsPath(incfile, buffer.temppath());
+ }
lyxerr[Debug::LATEX] << "incfile:" << incfile << endl;
lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
string const included_file = includedFilename(buffer, params_);
if (IsLyXFilename(included_file))
- writefile = ChangeExtension(writefile, ".sgml");
- else if (!buffer.temppath().empty() &&
- !features.nice() &&
- !isVerbatim(params_)) {
- incfile = subst(incfile, '/','@');
-#ifdef __EMX__
-// FIXME: It seems that the following is necessary (see latex() above)
-// incfile = subst(incfile, ':', '$');
-#endif
- writefile = AddName(buffer.temppath(), incfile);
- } else
+ writefile = ChangeExtension(included_file, ".sgml");
+ else
writefile = included_file;
+ if (!features.nice() && !isVerbatim(params_)) {
+ incfile = FileName(writefile).mangledFilename();
+ writefile = MakeAbsPath(incfile, buffer.temppath());
+ }
+
features.includeFile(include_label, writefile);
if (isVerbatim(params_))
using lyx::support::AddPath;
using lyx::support::bformat;
using lyx::support::createDirectory;
-using lyx::support::CreateLyXTmpDir;
+using lyx::support::createLyXTmpDir;
using lyx::support::FileInfo;
using lyx::support::FileSearch;
using lyx::support::GetEnv;
if (lyxerr.debugging(Debug::LYXRC))
lyxrc.print();
- os::setTmpDir(CreateLyXTmpDir(lyxrc.tempdir_path));
+ os::setTmpDir(createLyXTmpDir(lyxrc.tempdir_path));
+ if (os::getTmpDir().empty()) {
+ Alert::error(_("Could not create temporary directory"),
+ bformat(_("Could not create a temporary directory in\n"
+ "%1$s. Make sure that this\n"
+ "path exists and is writable and try again."),
+ lyxrc.tempdir_path));
+ // createLyXTmpDir() tries sufficiently hard to create a
+ // usable temp dir, so the probability to come here is
+ // close to zero. We therefore don't try to overcome this
+ // problem with e.g. asking the user for a new path and
+ // trying again but simply exit.
+ exit(EXIT_FAILURE);
+ }
+
if (lyxerr.debugging(Debug::INIT)) {
lyxerr << "LyX tmp dir: `" << os::getTmpDir() << '\'' << endl;
}
This is needed to ensure that the pop is done upon exit from methods
with more than one exit point or that can return as a response to
exceptions.
- @autor Lgb
+ @author Lgb
*/
struct pushpophelper {
///
// compatibility with versions older than 1.4.0 only
{ "\\use_pspell", LyXRC::RC_USE_SPELL_LIB },
{ "\\use_spell_lib", LyXRC::RC_USE_SPELL_LIB },
+ // compatibility with versions older than 1.4.0 only
{ "\\use_tempdir", LyXRC::RC_USETEMPDIR },
{ "\\user_email", LyXRC::RC_USER_EMAIL },
{ "\\user_name", LyXRC::RC_USER_NAME },
print_paper_dimension_flag = "-T";
document_path.erase();
tempdir_path = "/tmp";
- use_tempdir = true;
ps_command = "gs";
view_dvi_paper_option.erase();
default_papersize = PAPER_USLETTER;
case RC_USETEMPDIR:
if (lexrc.next()) {
- use_tempdir = lexrc.getBool();
+ lyxerr << "Ignoring obsolete use_tempdir flag." << endl;
}
break;
os << "\\tempdir_path \"" << tempdir_path << "\"\n";
}
case RC_USETEMPDIR:
- if (use_tempdir != system_lyxrc.use_tempdir) {
- os << "\\use_tempdir " << tostr(use_tempdir) << '\n';
- }
+ // Ignore it
case RC_ASCII_LINELEN:
if (ascii_linelen != system_lyxrc.ascii_linelen) {
os << "\\ascii_linelen " << ascii_linelen << '\n';
str = _("LyX will place its temporary directories in this path. They will be deleted when you quit LyX.");
break;
- case RC_USETEMPDIR:
- str = _("Select if you wish to use a temporary directory structure to store temporary TeX output.");
- break;
-
case RC_LASTFILES:
str = _("The file where the last-files information should be stored.");
break;
///
std::string tempdir_path;
///
- bool use_tempdir;
- ///
bool auto_region_delete;
/// flag telling whether lastfiles should be checked for existance
bool auto_reset_options;
return string();
string tmpf = tempName(string(), "lyxvclog");
+ if (tmpf.empty()) {
+ lyxerr[Debug::LYXVC] << "Could not generate logfile "
+ << tmpf << endl;
+ return string();
+ }
lyxerr[Debug::LYXVC] << "Generating logfile " << tmpf << endl;
vcs->getLog(tmpf);
return tmpf;
}
-bool Paragraph::isMultiLingual(BufferParams const & bparams)
+bool Paragraph::isMultiLingual(BufferParams const & bparams) const
{
Language const * doc_language = bparams.language;
Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
void changeLanguage(BufferParams const & bparams,
Language const * from, Language const * to);
///
- bool isMultiLingual(BufferParams const &);
+ bool isMultiLingual(BufferParams const &) const;
///
std::string const asString(Buffer const &,
+2004-02-21 Georg Baum <Georg.Baum@post.rwth-aachen.de>
+
+ * filetools.[Ch] (CreateBufferTmpDir): rename to createBufferTmpDir,
+ remove pathfor argument
+ * filetools.[Ch] (CreateLyXTmpDir): rename to createLyXTmpDir, try
+ harder to create a usable temp dir
+ * filetools.C (CreateTmpDir): rename to createTmpDir
+ filetools.[Ch] (unzipFile): add argument for output filename
+ * filename.h: fix doxygen warning
+
2004-02-01 Lars Gullik Bjonnes <larsbj@gullik.net>
* lstrings.h (contains_functor): delete
class FileName {
public:
FileName();
- /** \param filename the file in question. Must have an absolute path.
+ /** \param abs_filename the file in question. Must have an absolute path.
* \param save_abs_path how is the file to be output to file?
*/
FileName(std::string const & abs_filename, bool save_abs_path = true);
}
-string const CreateTmpDir(string const & tempdir, string const & mask)
+string const createTmpDir(string const & tempdir, string const & mask)
{
lyxerr[Debug::FILES]
- << "CreateTmpDir: tempdir=`" << tempdir << "'\n"
- << "CreateTmpDir: mask=`" << mask << '\'' << endl;
+ << "createTmpDir: tempdir=`" << tempdir << "'\n"
+ << "createTmpDir: mask=`" << mask << '\'' << endl;
string const tmpfl(tempName(tempdir, mask));
// lyx::tempName actually creates a file to make sure that it
// safe because of the gap between unlink and mkdir. (Lgb)
unlink(tmpfl);
- if (tmpfl.empty() || mkdir(tmpfl, 0700))
+ if (tmpfl.empty() || mkdir(tmpfl, 0700)) {
+ lyxerr << "LyX could not create the temporary directory '"
+ << tmpfl << "'" << endl;
return string();
+ }
return MakeAbsPath(tmpfl);
}
}
-string const CreateBufferTmpDir(string const & pathfor)
+string const createBufferTmpDir()
{
static int count;
- static string const tmpdir(pathfor.empty() ? os::getTmpDir() : pathfor);
// We are in our own directory. Why bother to mangle name?
// In fact I wrote this code to circumvent a problematic behaviour (bug?)
// of EMX mkstemp().
- string const tmpfl = tmpdir + "/lyx_tmpbuf" + tostr(count++);
+ string const tmpfl = os::getTmpDir() + "/lyx_tmpbuf" + tostr(count++);
if (mkdir(tmpfl, 0777)) {
+ lyxerr << "LyX could not create the temporary directory '"
+ << tmpfl << "'" << endl;
return string();
}
return tmpfl;
}
-string const CreateLyXTmpDir(string const & deflt)
+string const createLyXTmpDir(string const & deflt)
{
- if ((!deflt.empty()) && (deflt != "/tmp")) {
+ if (!deflt.empty() && deflt != "/tmp") {
if (mkdir(deflt, 0777)) {
+ if (IsDirWriteable(deflt))
+ // deflt could not be created because it
+ // did exist already, so let's create our own
+ // dir inside deflt.
#ifdef __EMX__
- Path p(user_lyxdir());
+ Path p(user_lyxdir());
+#endif
+ return createTmpDir(deflt, "lyx_tmpdir");
+ else
+ // some other error occured.
+#ifdef __EMX__
+ Path p(user_lyxdir());
#endif
- return CreateTmpDir(deflt, "lyx_tmpdir");
+ return createTmpDir("/tmp", "lyx_tmpdir");
} else
return deflt;
} else {
#ifdef __EMX__
Path p(user_lyxdir());
#endif
- return CreateTmpDir("/tmp", "lyx_tmpdir");
+ return createTmpDir("/tmp", "lyx_tmpdir");
}
}
}
-string const unzipFile(string const & zipped_file)
+string const unzipFile(string const & zipped_file, string const & unzipped_file)
{
- string const tempfile = unzippedFileName(zipped_file);
+ string const tempfile = unzipped_file.empty() ?
+ unzippedFileName(zipped_file) : unzipped_file;
// Run gunzip
string const command = "gunzip -c " + zipped_file + " > " + tempfile;
Systemcall one;
/// remove directory and all contents, returns 0 on success
int destroyDir(std::string const & tmpdir);
-///
-std::string const CreateBufferTmpDir(std::string const & pathfor = std::string());
+/// Creates the per buffer temporary directory
+std::string const createBufferTmpDir();
/// Creates directory. Returns true on success
bool createDirectory(std::string const & name, int permissions);
-///
-std::string const CreateLyXTmpDir(std::string const & deflt);
+/** Creates the global LyX temp dir.
+ \p deflt can be an existing directory name. In this case a new directory
+ inside \p deflt is created. If \p deflt does not exist yet, \p deflt is
+ created and used as the temporary directory.
+ \return the tmp dir name or string() if something went wrong.
+ */
+std::string const createLyXTmpDir(std::string const & deflt);
/** Find file by searching several directories.
Uses a string of paths separated by ";"s to find a file to open.
/// check for zipped file
bool zippedFile(std::string const & name);
-/// \return the name that LyX will give to the unzipped file.
+/** \return the name that LyX will give to the unzipped file \p zipped_file
+ if the second argument of unzipFile() is empty.
+ */
std::string const unzippedFileName(std::string const & zipped_file);
-/// unzip a file
-std::string const unzipFile(std::string const & zipped_file);
+/** Unzip \p zipped_file.
+ The unzipped file is named \p unzipped_file if \p unzipped_file is not
+ empty, and unzippedFileName(\p zipped_file) otherwise.
+ Will overwrite an already existing unzipped file without warning.
+ */
+std::string const unzipFile(std::string const & zipped_file,
+ std::string const & unzipped_file = std::string());
/// Returns true is path is absolute
bool AbsolutePath(std::string const & path);