Qfile file size




















Sets the function for decoding 8-bit file names. The default uses the locale-specific 8-bit encoding. See also setEncodingFunction and decodeName. Sets the function for encoding Unicode file names. The default encodes in the locale-specific 8-bit encoding. See also encodeName and setDecodingFunction. Sets the name of the file. The name can have no path, a relative path, or an absolute path. If the file name has no path or a relative path, the path used will be the application's current directory path at the time of the open call.

Sets the permissions for the file to the permissions specified. Returns true if successful, or false if the permissions cannot be modified. See also permissions and setFileName. Returns the absolute path of the file or directory referred to by the symlink or shortcut on Windows specified by fileName , or returns an empty string if the fileName does not correspond to a symbolic link.

This name may not represent an existing file; it is only a string. QFile::exists returns true if the symlink points to an existing file. Returns the absolute path of the file or directory a symlink or shortcut on Windows points to, or a an empty string if the object isn't a symbolic link. Documentation contributions included herein are the copyrights of their respective owners. Qt and respective logos are trademarks of The Qt Company Ltd.

All other trademarks are property of their respective owners. Detailed Description The QFile class provides an interface for reading from and writing to files. QFile file "in. QFile file "out. QFile::ReadError 1 An error occurred when reading from the file. QFile::WriteError 2 An error occurred when writing to the file. QFile::FatalError 3 A fatal error occurred. QFile::AbortError 6 The operation was aborted. QFile::UnspecifiedError 8 An unspecified error occurred. QFile::RemoveError 9 The file could not be removed.

QFile::RenameError 10 The file could not be renamed. QFile::PositionError 11 The position in the file could not be changed. QFile::ResizeError 12 The file could not be resized. QFile::PermissionsError 13 The file could not be accessed. QFile::CopyError 14 The file could not be copied. Constant Value Description QFile::AutoCloseHandle 0x The file handle passed into open should be closed by close , the default behaviour is that close just flushes the file and the application is responsible for closing the file handle.

When opening a file by name, this flag is ignored as Qt always "owns" the file handle and must close it. The application must ensure that close is called. QFile::WriteOwner 0x The file is writable by the owner of the file. QFile::ExeOwner 0x The file is executable by the owner of the file. QFile::ReadUser 0x The file is readable by the user. QFile::WriteUser 0x The file is writable by the user.

QFile::ExeUser 0x The file is executable by the user. QFile::ReadGroup 0x The file is readable by the group. QFile::WriteGroup 0x The file is writable by the group. QFile::ExeGroup 0x The file is executable by the group. QFile::ReadOther 0x The file is readable by anyone. QFile::WriteOther 0x The file is writable by anyone. QFile::ExeOther 0x The file is executable by anyone.

Returns true if the end of the file has been reached; otherwise returns false. See also QIODevice::close. The source file is closed before it is copied. See also setFileName. See also rename. FileError QFile:: error const Returns the file error status. See also unsetError. If the file is not open, or there is an error, handle returns I'm using QFile::size to check the filesize on the output file created by the dump.

If the dump operation succeeded, the file should contain text data. If the dump failed for instance, because the user entered the wrong password QProcess still creates the output file but it would be empty, i. I could then mark the bad file for deletion. Unfortunately, QFile::size always returns zero even if the size is checked when the file is open "output" is a QFile object created higher up in the function :. I'm not sure why this is happening. I've eliminated the possibility of it being because the QFile object doesn't exist when instantiated because QFile::size returns 0 even when I overwrite an existing file.

This code is being built against Qt 4. Hi pwizard. Did you tray errorString to verify if there are same error with file? I just tried creating another QFile object with the same path as "output" just in case Qt couldn't tell that the original file had changed.

Unfortunately, it didn't work--size is still returning 0. However, dump. The output should be identical but it's not. Could this be a bug in Qt or is something else going on here? File size: 0 bytes. I haven't been able to reproduce it on my PC though Qt 5. I know these files are good because I can read them with no problem whatsoever in a text editor. The file's ownership is available from owner , ownerId , group and groupId. You can examine a file's permissions and ownership in a single statement using the permission function.

Note: On NTFS file systems, ownership and permissions checking is disabled by default for performance reasons. To enable it, include the following line:. Some of QFileInfo's functions query the file system, but for performance reasons, some functions only operate on the file name itself. For example: To return the absolute path of a relative file name, absolutePath has to query the file system.

The path function, however, can work on the file name directly, and so it is faster. Because files can be changed by other users or programs, or even by other parts of the same program, there is a function that refreshes the file information: refresh. If you want to switch off a QFileInfo's caching and force it to access the file system every time you request information from it call setCaching false.

Constructs a new QFileInfo that gives information about the given file in the directory dir. If file is an absolute path, then the directory specified by dir will be disregarded.

Constructs a new QFileInfo that gives information about the given file. The file can also include an absolute or relative path. Makes a copy of the given fileinfo and assigns it to this QFileInfo.

See also dir , filePath , fileName , and isRelative. The absolute path name consists of the full path and the file name. QFileInfo will uppercase drive letters.

Note that QDir does not do this. The code snippet below shows this. This function returns the same as filePath , unless isRelative is true. In contrast to canonicalFilePath , symbolic links or redundant ". Warning: If filePath is empty the behavior of this function is undefined. See also filePath , canonicalFilePath , and isRelative. In contrast to canonicalPath symbolic links or redundant ". The base name consists of all characters in the file up to but not including the first '.

The base name of a file is computed equally on all platforms, independent of file naming conventions e. See also fileName , suffix , completeSuffix , and completeBaseName.

If the file birth time is not available, this function returns an invalid QDateTime. See also lastModified , lastRead , and metadataChangeTime. On all other platforms an empty QString is returned. See also isBundle , filePath , baseName , and suffix.

See also setCaching and refresh. Returns the canonical path including the file name, i. See also filePath , absoluteFilePath , and dir.

Returns the file's path canonical path excluding the file name , i. See also path and absolutePath. The complete base name consists of all characters in the file up to but not including the last '.

See also fileName , suffix , completeSuffix , and baseName. The complete suffix consists of all characters in the file after but not including the first '. See also fileName , suffix , baseName , and completeBaseName.

Note: The QDir returned always corresponds to the object's parent directory, even if the QFileInfo represents a directory. Note: Using this function is faster than using QFileInfo file.

Note that, if this QFileInfo object is given a path ending in a slash, the name of the file is considered empty. See also isRelative , filePath , baseName , and suffix. Returns the file time specified by time. If the time cannot be determined, an invalid date time is returned. Returns the group of the file. On Windows, on systems where files do not have groups, or if an error occurs, an empty string is returned.

If the file is a symlink, this function returns the owning group of the target not the symlink. See also groupId , owner , and ownerId. If the file is a symlink, this function returns the id of the group owning the target not the symlink.

See also group , owner , and ownerId. Returns true if the file path is absolute, otherwise returns false i. Returns true if this object points to a bundle or to a symbolic link to a bundle on macOS and iOS; otherwise returns false.

If the file is a symlink, this function returns true if the target is a bundle not the symlink. See also isDir , isSymLink , and isFile. Returns true if this object points to a directory or to a symbolic link to a directory; otherwise returns false.



0コメント

  • 1000 / 1000