class Poco::TemporaryFile
Overview
The TemporaryFile class helps with the handling of temporary files. More…
#include <TemporaryFile.h> class TemporaryFile: public Poco::File { public: // construction TemporaryFile(); TemporaryFile(const std::string& tempDir); // methods void keep(); void keepUntilExit(); static void registerForDeletion(const std::string& path); static std::string tempName(const std::string& tempDir = ""); };
Inherited Members
public: // typedefs typedef FileSizeImpl FileSize; // methods File& operator=(const File& file); File& operator=(const std::string& path); File& operator=(const char* path); File& operator=(const Path& path); void swap(File& file); const std::string& path() const; bool exists() const; bool canRead() const; bool canWrite() const; bool canExecute() const; bool isFile() const; bool isLink() const; bool isDirectory() const; bool isDevice() const; bool isHidden() const; Timestamp created() const; Timestamp getLastModified() const; File& setLastModified(const Timestamp& ts); FileSize getSize() const; File& setSize(FileSize size); File& setWriteable(bool flag = true); File& setReadOnly(bool flag = true); File& setExecutable(bool flag = true); void copyTo(const std::string& path) const; void moveTo(const std::string& path); void renameTo(const std::string& path); void remove(bool recursive = false); bool createFile(); bool createDirectory(); void createDirectories(); void list(std::vector<std::string>& files) const; void list(std::vector<File>& files) const; bool operator==(const File& file) const; bool operator!=(const File& file) const; bool operator<(const File& file) const; bool operator<=(const File& file) const; bool operator>(const File& file) const; bool operator>=(const File& file) const; static void handleLastError(const std::string& path); protected: // typedefs typedef UInt64 FileSizeImpl; // methods const std::string& getPathImpl() const; void setPath(const std::string& path); void swapImpl(FileImpl& file); void setPathImpl(const std::string& path); const std::string& getPathImpl() const; bool existsImpl() const; bool canReadImpl() const; bool canWriteImpl() const; bool canExecuteImpl() const; bool isFileImpl() const; bool isDirectoryImpl() const; bool isLinkImpl() const; bool isDeviceImpl() const; bool isHiddenImpl() const; Timestamp createdImpl() const; Timestamp getLastModifiedImpl() const; void setLastModifiedImpl(const Timestamp& ts); FileSizeImpl getSizeImpl() const; void setSizeImpl(FileSizeImpl size); void setWriteableImpl(bool flag = true); void setExecutableImpl(bool flag = true); void copyToImpl(const std::string& path) const; void renameToImpl(const std::string& path); void removeImpl(); bool createFileImpl(); bool createDirectoryImpl(); static void handleLastError(const std::string& path); static void handleLastErrorImpl(const std::string& path); static void convertPath( const std::string& utf8Path, std::wstring& utf16Path ); void copyDirectory(const std::string& path) const;
Detailed Documentation
The TemporaryFile class helps with the handling of temporary files.
A unique name for the temporary file is automatically chosen and the file is placed in the directory reserved for temporary files (see Path::temp()). Obtain the path by calling the path() method (inherited from File).
The TemporaryFile class does not actually create the file - this is up to the application. The class does, however, delete the temporary file - either in the destructor, or immediately before the application terminates.
Construction
TemporaryFile()
Creates the TemporaryFile.
TemporaryFile(const std::string& tempDir)
Creates the TemporaryFile using the given directory.
Methods
void keep()
Disables automatic deletion of the file in the destructor.
void keepUntilExit()
Disables automatic deletion of the file in the destructor, but registers the file for deletion at process termination.
static void registerForDeletion(const std::string& path)
Registers the given file for deletion at process termination.
static std::string tempName(const std::string& tempDir = "")
Returns a unique path name for a temporary file in the system’s scratch directory (see Path::temp()) if tempDir is empty or in the directory specified in tempDir otherwise.