Skip to content

Commit

Permalink
Extend documentation for QFile:copy()
Browse files Browse the repository at this point in the history
- Add information about symlinks and file metadata.
- Reflow text.
- Extract text common to both overloads to a .qdocinc file
  for consistency and to avoid duplication.

Pick-to: 6.2 6.1 5.15
Fixes: QTBUG-94706
Change-Id: I3c730fd63f4018a1a573bb56751fedd2270a3247
Reviewed-by: Thiago Macieira <[email protected]>
  • Loading branch information
paulwicking committed Jun 23, 2021
1 parent cbe6567 commit cc2fdce
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
11 changes: 11 additions & 0 deletions src/corelib/doc/src/includes/qfile-copy.qdocinc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
This file is closed before it is copied.

If the copied file is a symbolic link (symlink), the
file it refers to is copied, not the link itself. With the
exception of permissions, which are copied, no other file metadata
is copied.

Returns \c true if successful; otherwise returns \c false.

Note that if a file with the name \a newName already exists,
copy() returns \c false. This means QFile will not overwrite it.
14 changes: 4 additions & 10 deletions src/corelib/io/qfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,13 +755,9 @@ QFile::link(const QString &fileName, const QString &linkName)
}

/*!
Copies the file currently specified by fileName() to a file called
\a newName. Returns \c true if successful; otherwise returns \c false.
Copies the file named fileName() to \a newName.
Note that if a file with the name \a newName already exists,
copy() returns \c false (i.e. QFile will not overwrite it).
The source file is closed before it is copied.
\include qfile-copy.qdocinc
\sa setFileName()
*/
Expand Down Expand Up @@ -867,11 +863,9 @@ QFile::copy(const QString &newName)
/*!
\overload
Copies the file \a fileName to \a newName. Returns \c true if successful;
otherwise returns \c false.
Copies the file named \a fileName to \a newName.
If a file with the name \a newName already exists, copy() returns \c false
(i.e., QFile will not overwrite it).
\include qfile-copy.qdocinc
\sa rename()
*/
Expand Down

0 comments on commit cc2fdce

Please sign in to comment.