|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.internal.QSignalEmitterInternal
com.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.core.QObject
com.trolltech.qt.core.QIODevice
com.trolltech.qt.core.QFile
com.trolltech.qt.core.QTemporaryFile
public class QTemporaryFile
The QTemporaryFile class is an I/O device that operates on temporary files. QTemporaryFile is used to create unique temporary files safely. The file itself is created by calling open()
. The name of the temporary file is guaranteed to be unique (i.e., you are guaranteed to not overwrite an existing file), and the file will subsequently be removed upon destruction of the QTemporaryFile object. This is an important technique that avoids data corruption for applications that store data in temporary files. The file name is either auto-generated, or created based on a template, which is passed to QTemporaryFile's constructor.
Example:
{ QTemporaryFile file = new QTemporaryFile(); if (file.open()) { // file.fileName() returns the unique file name } // the QTemporaryFile destructor removes the temporary file }Reopening a QTemporaryFile after calling
close()
is safe. For as long as the QTemporaryFile object itself is not destroyed, the unique temporary file will exist and be kept open internally by QTemporaryFile. The file name of the temporary file can be found by calling fileName(). Note that this is only defined while the file is open; the function returns an empty string before the file is opened and after it is closed.
A temporary file will have some static part of the name and some part that is calculated to be unique. The default filename qt_temp will be placed into the temporary path as returned by QDir::tempPath()
. If you specify your own filename, a relative file path will not be placed in the temporary directory by default, but be relative to the current working directory.
Specified filenames can contain the following template XXXXXX, which will be replaced by the auto-generated portion of the filename. Note that the template is case sensitive. If the template is not present in the filename, QTemporaryFile appends the generated part to the filename given.
QDir::tempPath()
, and QFile
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.trolltech.qt.core.QFile |
---|
QFile.FileError, QFile.MemoryMapFlags, QFile.Permission, QFile.Permissions |
Nested classes/interfaces inherited from class com.trolltech.qt.core.QIODevice |
---|
QIODevice.OpenMode, QIODevice.OpenModeFlag |
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9 |
Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal |
Field Summary |
---|
Fields inherited from class com.trolltech.qt.core.QIODevice |
---|
aboutToClose, bytesWritten, readChannelFinished, readyRead |
Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
currentSender |
Constructor Summary | |
---|---|
QTemporaryFile()
Constructs a QTemporaryFile in QDir::tempPath() , using the file template "qt_temp.XXXXXX". |
|
QTemporaryFile(QObject parent)
Constructs a QTemporaryFile (with the given parent) in QDir::tempPath() , using the file template "qt_temp.XXXXXX". |
|
QTemporaryFile(java.lang.String templateName)
Constructs a QTemporaryFile with a template filename of templateName. |
|
QTemporaryFile(java.lang.String templateName,
QObject parent)
Constructs a QTemporaryFile with a template filename of templateName and the specified parent. |
Method Summary | |
---|---|
boolean |
autoRemove()
Returns true if the QTemporaryFile is in auto remove mode. |
static QTemporaryFile |
createLocalFile(QFile file)
If file is not on a local disk, a temporary file is created on a local disk, file is copied into the temporary local file, and a pointer to the temporary local file is returned. |
static QTemporaryFile |
createLocalFile(java.lang.String fileName)
Works on the given fileName rather than an existing QFile object. |
java.lang.String |
fileTemplate()
Returns the set file template. |
boolean |
open()
A QTemporaryFile will always be opened in QIODevice::ReadWrite mode, this allows easy access to the data in the file. |
void |
setAutoRemove(boolean b)
Sets the QTemporaryFile into auto-remove mode if b is true. |
void |
setFileTemplate(java.lang.String name)
Sets the static portion of the file name to name. |
java.lang.String |
uniqueFilename()
Returns the complete unique filename backing the QTemporaryFile object. |
Methods inherited from class com.trolltech.qt.core.QFile |
---|
copy, copy, decodeName, decodeName, encodeName, error, exists, exists, fileName, flush, handle, link, link, open, open, open, permissions, permissions, remove, remove, rename, rename, resize, resize, setFileName, setPermissions, setPermissions, setPermissions, setPermissions, symLinkTarget, symLinkTarget, unsetError |
Methods inherited from class com.trolltech.qt.core.QIODevice |
---|
atEnd, bytesAvailable, bytesToWrite, canReadLine, close, errorString, getByte, isOpen, isReadable, isSequential, isTextModeEnabled, isWritable, open, openMode, peek, peek, pos, putByte, read, read, readAll, readData, readLine, readLine, readLine, readLineData, reset, seek, setErrorString, setOpenMode, setOpenMode, setTextModeEnabled, size, ungetByte, waitForBytesWritten, waitForReadyRead, write, write, writeData |
Methods inherited from class com.trolltech.qt.core.QObject |
---|
childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread |
Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
__qt_signalInitialization |
Methods inherited from class java.lang.Object |
---|
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Constructor Detail |
---|
public QTemporaryFile()
QDir::tempPath()
, using the file template "qt_temp.XXXXXX". The file is stored in the system's temporary directory. setFileTemplate()
, and QDir::tempPath()
.
public QTemporaryFile(QObject parent)
QDir::tempPath()
, using the file template "qt_temp.XXXXXX". setFileTemplate()
.
public QTemporaryFile(java.lang.String templateName)
If templateName is a relative path, the path will be relative to the current working directory. You can use QDir::tempPath()
to construct templateName if you want use the system's temporary directory.
open()
, and fileTemplate()
.
public QTemporaryFile(java.lang.String templateName, QObject parent)
If templateName is a relative path, the path will be relative to the current working directory. You can use QDir::tempPath()
to construct templateName if you want use the system's temporary directory.
open()
, and fileTemplate()
.
Method Detail |
---|
public final boolean autoRemove()
Auto-remove is on by default.
setAutoRemove()
, and remove()
.
public final java.lang.String uniqueFilename()
fileTemplate()
plus additional characters to make it unique. fileTemplate()
.
public final java.lang.String fileTemplate()
QDir::tempPath()
. setFileTemplate()
.
public final boolean open()
QIODevice::ReadWrite
mode, this allows easy access to the data in the file. This function will return true upon success and will set the fileName() to the unique filename used.
public final void setAutoRemove(boolean b)
Auto-remove is on by default.
autoRemove()
, and remove()
.
public final void setFileTemplate(java.lang.String name)
If name contains a relative file path, the path will be relative to the current working directory. You can use QDir::tempPath()
to construct name if you want use the system's temporary directory.
fileTemplate()
.
public static QTemporaryFile createLocalFile(QFile file)
public static QTemporaryFile createLocalFile(java.lang.String fileName)
QFile
object.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |