ну можно попробовать просто стянуть код из 4-ки
Посмотрел реализацию, она находится в QFSFileEngine
Для виндовоза:C++ (Qt)
bool QFSFileEngine::mkdir(const QString &name, bool createParentDirectories) const
{
QString dirName = name;
if (createParentDirectories) {
dirName = QDir::toNativeSeparators(QDir::cleanPath(dirName));
// We spefically search for / so \ would break it..
int oldslash = -1;
if (dirName.startsWith(QLatin1String("\\\\"))) {
// Don't try to create the root path of a UNC path;
// CreateDirectory() will just return ERROR_INVALID_NAME.
for (int i = 0; i < dirName.size(); ++i) {
if (dirName.at(i) != QDir::separator()) {
oldslash = i;
break;
}
}
if (oldslash != -1)
oldslash = dirName.indexOf(QDir::separator(), oldslash);
}
for (int slash=0; slash != -1; oldslash = slash) {
slash = dirName.indexOf(QDir::separator(), oldslash+1);
if (slash == -1) {
if(oldslash == dirName.length())
break;
slash = dirName.length();
}
if (slash) {
QString chunk = dirName.left(slash);
bool existed = false;
if (!isDirPath(chunk, &existed) && !existed) {
if (!mkDir(chunk))
return false;
}
}
}
return true;
}
return mkDir(name);
}
для *nix'ов:C++ (Qt)
bool QFSFileEngine::mkdir(const QString &name, bool createParentDirectories) const
{
QString dirName = name;
if (createParentDirectories) {
dirName = QDir::cleanPath(dirName);
for(int oldslash = -1, slash=0; slash != -1; oldslash = slash) {
slash = dirName.indexOf(QDir::separator(), oldslash+1);
if (slash == -1) {
if (oldslash == dirName.length())
break;
slash = dirName.length();
}
if (slash) {
QByteArray chunk = QFile::encodeName(dirName.left(slash));
QT_STATBUF st;
if (QT_STAT(chunk, &st) != -1) {
if ((st.st_mode & S_IFMT) != S_IFDIR)
return false;
} else if (::mkdir(chunk, 0777) != 0) {
return false;
}
}
}
return true;
}
#if defined(Q_OS_DARWIN) // Mac X doesn't support trailing /'s
if (dirName[dirName.length() - 1] == QLatin1Char('/'))
dirName = dirName.left(dirName.length() - 1);
#endif
return (::mkdir(QFile::encodeName(dirName), 0777) == 0);
}