X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fsupport%2FTempFile.h;h=16efede3ab57880e54bbefd7ac71a2037510db36;hb=b96ce9a9c101a711ef8a1cdd5d6fe812a18966da;hp=c9342f91f2a6bfe38e4bd661f6087dce92827047;hpb=47721216f0d0959e4337e399fdccd50f9eba8243;p=lyx.git diff --git a/src/support/TempFile.h b/src/support/TempFile.h index c9342f91f2..16efede3ab 100644 --- a/src/support/TempFile.h +++ b/src/support/TempFile.h @@ -24,14 +24,25 @@ class FileName; * The file is created in the constructor, and deleted in the destructor. * You may do anything with the file (including deletion), but the instance * of this class must stay alive as long as the file is needed. + * There is only one exception to this rule: + * If the file is supposed to be used by a different process then you need + * to be aware of OS specific file locking semantics: On windows, the file + * is opened with exclusive rights for the process which opened it. This + * is not the case on other OSes. Therefore, if the file is supposed to be + * used by a different process you need to sometheing similar to TempName + * in InsetExternal.cpp. */ class TempFile { + /// noncopyable + TempFile(TempFile const &); + /// nonassignable + TempFile & operator=(TempFile const &); public: /** *Create a temporary file with the given mask. - * \p mask must be in filesystem encoding, if it contains a - * relative path, the template file will be created in the global - * temporary directory as given by 'package().temp_dir()'. + * \p mask must be in filesystem encoding, the template file + * will be created in the global temporary directory as given + * by 'package().temp_dir()'. * If the mask contains "XXXXXX" this portion will be replaced by * a uniquely generated string. If it does not contain this portion, * it will be automatically appended using a dot. Therefore, please @@ -46,6 +57,13 @@ public: * This is empty if the file could not be created. */ FileName name() const; + /** + * Set whether the file should be automatically deleted in the + * destructor. + * Automatic deletion is the default, but it can be switched off if + * the file should be kept, because it should be renamed afterwards. + */ + void setAutoRemove(bool autoremove); private: /// struct Private;