KCoreAddons

kfileutils.h
1 /*
2  This file is part of the KDE libraries
3 
4  SPDX-FileCopyrightText: 2000-2005 David Faure <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-only
7 */
8 #ifndef KFILEUTILS_H
9 #define KFILEUTILS_H
10 
11 #include "kcoreaddons_export.h"
12 
13 #include <QString>
14 #include <QUrl>
15 
16 /**
17  * @short A namespace for KFileUtils globals
18  *
19  */
20 namespace KFileUtils
21 {
22 /**
23  * Given a directory path and a string representing a file or directory
24  * (which usually exist already), this function returns a suggested name
25  * for a file/directory that doesn't exist in @p baseURL.
26  *
27  * The suggested file name is of the form "foo (1)", "foo (2)" etc.
28  *
29  * For local URLs, this function will check if there is already a file/directory
30  * with the new suggested name and will keep incrementing the number in the above
31  * format until it finds one that doesn't exist. Note that this function uses a
32  * blocking I/O call (using QFileInfo) to check the existence of the file/directory,
33  * this could be problematic for network mounts (e.g. SMB, NFS) as these are treated
34  * as local files by the upstream QFile code. An alternative is to use makeSuggestedName()
35  * and use KIO to stat the new file/directory in an asynchronous way.
36  *
37  * @since 5.61
38  */
39 KCOREADDONS_EXPORT QString suggestName(const QUrl &baseURL, const QString &oldName);
40 
41 /**
42  * Given a string, "foo", representing a file/directory (which usually exists already),
43  * this function returns a suggested name for a file/directory in the form "foo (1)",
44  * "foo (2)" etc.
45  *
46  * Unlike the suggestName() method, this function doesn't check if there is a file/directory
47  * with the newly suggested name; the idea being that this responsibility falls on
48  * the caller, e.g. one can use KIO::stat() to check asynchronously whether the new
49  * name already exists (in its parent directory) or not.
50  *
51  * @since 5.76
52  */
53 KCOREADDONS_EXPORT QString makeSuggestedName(const QString &oldName);
54 
55 }
56 #endif
KCOREADDONS_EXPORT QString makeSuggestedName(const QString &oldName)
Given a string, "foo", representing a file/directory (which usually exists already), this function returns a suggested name for a file/directory in the form "foo (1)", "foo (2)" etc.
Definition: kfileutils.cpp:15
KCOREADDONS_EXPORT QString suggestName(const QUrl &baseURL, const QString &oldName)
Given a directory path and a string representing a file or directory (which usually exist already)...
Definition: kfileutils.cpp:55
A namespace for KFileUtils globals.
Definition: kfileutils.h:20
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Apr 18 2021 23:02:02 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.