36 #include <QStringList> 37 #if QT_VERSION >= 0x050a00 38 #include <QRandomGenerator> 56 bool isFolderMarked = name.endsWith(
'/');
57 QString baseName = name.left( name.size() - int( isFolderMarked));
59 QString retVal = convertBaseName( baseName, nameF);
68 QString convertBaseName(
const QString& name, NameF nameF)
72 if (name.isEmpty() && !nameF.is( nameF.EmptyOk))
74 else if ((name !=
"@") || !nameF.is( nameF.EmptyOk))
84 if (path.startsWith(
'/'))
return path;
92 int from = path.endsWith(
'/') ? -2 : -1;
93 int pos = path.lastIndexOf(
'/', from);
95 if (pos < 0)
return path;
103 if (!parentPath_.endsWith(
'/')) parentPath_ +=
'/';
104 if (!posterityPath.startsWith( parentPath_))
return QString();
106 int i = posterityPath.indexOf(
'/', parentPath_.size());
108 return posterityPath.left(i + 1);
110 return posterityPath;
114 QString
changeBasePath(
const QString& oldBasePath,
const QString& newBasePath,
const QString& path)
116 QString oldBasePath_ = oldBasePath;
117 if (!oldBasePath_.endsWith(
'/')) oldBasePath_ +=
'/';
118 QString newBasePath_ = newBasePath;
119 if (!newBasePath_.endsWith(
'/')) newBasePath_ +=
'/';
121 if (newBasePath_ == oldBasePath_)
return path;
122 if (!path.startsWith( oldBasePath_))
return path;
124 return newBasePath_ + path.mid( oldBasePath_.size());
131 if (!parentPath_.endsWith(
'/')) parentPath_ +=
'/';
140 if (!retPath.endsWith(
'/'))
142 retPath += childRelPath;
152 nameF.set( nameF.
EmptyOk,
false);
158 QString pathNorm = path.trimmed();
159 bool isFolder = pathNorm.isEmpty() || pathNorm.endsWith(
"/");
160 if (isFolder && !pathNorm.isEmpty())
161 pathNorm.resize( pathNorm.size() - 1);
163 QStringList linkNames = pathNorm.split(
"/");
164 bool needSeparator =
false;
166 for (
int i = 0; i < linkNames.size(); i++) {
167 QString linkName = linkNames.at(i);
168 if (linkName.isEmpty() && i == 0)
174 needSeparator =
true;
176 if (isFolder && !pathNorm.isEmpty())
185 QString retPath = path;
186 if (retPath.endsWith(
"/"))
188 if (!retPath.contains(
"/"))
return QString();
190 retPath.resize( retPath.lastIndexOf(
"/") + 1);
197 if (path.endsWith(
'/'))
return path;
199 if (path.endsWith(
'!'))
return path.left( path.size() - 1);
212 return path.endsWith(
'/');
218 return path.endsWith(
'!');
224 QUuid uuid = QUuid::createUuid();
228 retVal += uuid.toString();
237 return host + ((info.isEmpty() || info == host) ? QString()
238 : (
" [" + info +
"]"));
244 QString retVal = hostWithInfo;
245 int pos = retVal.indexOf(
" ");
255 return ptr == arnNullptr;
261 #if QT_VERSION >= 0x050a00 262 if (
sizeof(uint) >=
sizeof(quint64))
263 return QRandomGenerator::global()->generate64();
265 return QRandomGenerator::global()->generate();
QString childPath(const QString &parentPath, const QString &posterityPath)
Get substring for child from a path (posterityPath)
QString convertName(const QString &name, NameF nameF)
Convert a name to a specific format.
QString hostFromHostWithInfo(const QString &hostWithInfo)
Get the host from the HostWithInfo string.
const QString pathDiscover
Path: "/@/test" ==> "//test", Item: "@" ==> "".
QString fullPath(const QString &path)
Convert a path to a full absolute path.
bool isNullPtr(const void *ptr)
const QString pathLocalSys
Only on path, no effect on discrete names. "/test/value" ==> "test/value".
QString addPath(const QString &parentPath, const QString &childRelPath, Arn::NameF nameF)
Make a path from a parent and an additional relative path.
const QString pathDiscoverConnect
QString makePath(const QString &parentPath, const QString &itemName)
Make a path from a parent and an item name.
QString changeBasePath(const QString &oldBasePath, const QString &newBasePath, const QString &path)
Change the base (start) of a path.
QString uuidPath(const QString &path)
Get a path to an Arn Object with a unique uuid name.
QString convertPath(const QString &path, Arn::NameF nameF)
Convert a path to a specific format.
QString twinPath(const QString &path)
Get the bidirectional twin to a given path
const QString pathServerSessions
QString providerPathIf(const QString &path, bool giveProviderPath)
Get provider path or requester path
const QString pathDiscoverThis
QString parentPath(const QString &path)
Get the parent to a given path
QString itemName(const QString &path)
The last part of a path
QString makeHostWithInfo(const QString &host, const QString &info)
Make a combined host and info string, i.e. HostWithInfo
bool isFolderPath(const QString &path)
Test if path is a folder path
Only on discrete names, no effect on path. "test/" ==> "test".
bool isProviderPath(const QString &path)
Test if path is a provider path