4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
23 * Class for safely creating temporary files without race conditions.
24 * The file is created in the constructor, and deleted in the destructor.
25 * You may do anything with the file (including deletion), but the instance
26 * of this class must stay alive as long as the file is needed.
27 * There is only one exception to this rule:
28 * If the file is supposed to be used by a different process then you need
29 * to be aware of OS specific file locking semantics: On windows, the file
30 * is opened with exclusive rights for the process which opened it. This
31 * is not the case on other OSes. Therefore, if the file is supposed to be
32 * used by a different process you need to sometheing similar to TempName
33 * in InsetExternal.cpp.
37 TempFile(TempFile const &);
39 TempFile & operator=(TempFile const &);
42 *Create a temporary file with the given mask.
43 * \p mask must be in filesystem encoding, the template file
44 * will be created in the global temporary directory as given
45 * by 'package().temp_dir()'.
46 * If the mask contains "XXXXXX" this portion will be replaced by
47 * a uniquely generated string. If it does not contain this portion,
48 * it will be automatically appended using a dot. Therefore, please
49 * specify the "XXXXXX" portion if the extension of the generated
50 * name is important (e.g. for the converter machinery).
52 TempFile(std::string const & mask);
53 TempFile(FileName const & temp_dir, std::string const & mask);
56 * Get the name of the temporary file.
57 * This is empty if the file could not be created.
59 FileName name() const;
61 * Set whether the file should be automatically deleted in the
63 * Automatic deletion is the default, but it can be switched off if
64 * the file should be kept, because it should be renamed afterwards.
66 void setAutoRemove(bool autoremove);
73 } // namespace support