Check existing XDG folders before localization of the name.

Some standard XDG folders may exist before the information is stored
in ~/.config/user-dirs.dirs. Checking existing folders will prevent
the creation of localized folders in addition to existing English ones.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit dc699b4fd4)
r14.0.x
Slávek Banko 5 years ago
parent 8000d14291
commit 79bf82135e
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -140,38 +140,70 @@ static void readXdgUserDirs(TQString *desktop, TQString *documents, TQString *do
// Use sane values in case some paths are missing // Use sane values in case some paths are missing
if (desktop->isEmpty()) if (desktop->isEmpty())
{
*desktop = TQDir::homeDirPath() + "/" + "Desktop" + "/";
if (!TQDir(*desktop).exists())
{ {
*desktop = TQDir::homeDirPath() + "/" + i18n("Desktop") + "/"; *desktop = TQDir::homeDirPath() + "/" + i18n("Desktop") + "/";
} }
}
if (documents->isEmpty()) if (documents->isEmpty())
{
*documents = TQDir::homeDirPath() + "/" + "Documents" + "/";
if (!TQDir(*documents).exists())
{ {
*documents = TQDir::homeDirPath() + "/" + i18n("Documents") + "/"; *documents = TQDir::homeDirPath() + "/" + i18n("Documents") + "/";
} }
}
if (download->isEmpty()) if (download->isEmpty())
{
*download = TQDir::homeDirPath() + "/" + "Downloads" + "/";
if (!TQDir(*download).exists())
{ {
*download = TQDir::homeDirPath() + "/" + i18n("Downloads") + "/"; *download = TQDir::homeDirPath() + "/" + i18n("Downloads") + "/";
} }
}
if (music->isEmpty()) if (music->isEmpty())
{
*music = TQDir::homeDirPath() + "/" + "Music" + "/";
if (!TQDir(*music).exists())
{ {
*music = TQDir::homeDirPath() + "/" + i18n("Music") + "/"; *music = TQDir::homeDirPath() + "/" + i18n("Music") + "/";
} }
}
if (pictures->isEmpty()) if (pictures->isEmpty())
{
*pictures = TQDir::homeDirPath() + "/" + "Pictures" + "/";
if (!TQDir(*pictures).exists())
{ {
*pictures = TQDir::homeDirPath() + "/" + i18n("Pictures") + "/"; *pictures = TQDir::homeDirPath() + "/" + i18n("Pictures") + "/";
} }
}
if (publicShare->isEmpty()) if (publicShare->isEmpty())
{
*publicShare = TQDir::homeDirPath() + "/" + "Public" + "/";
if (!TQDir(*publicShare).exists())
{ {
*publicShare = TQDir::homeDirPath() + "/" + i18n("Public") + "/"; *publicShare = TQDir::homeDirPath() + "/" + i18n("Public") + "/";
} }
}
if (templates->isEmpty()) if (templates->isEmpty())
{
*templates = TQDir::homeDirPath() + "/" + "Templates" + "/";
if (!TQDir(*templates).exists())
{ {
*templates = TQDir::homeDirPath() + "/" + i18n("Templates") + "/"; *templates = TQDir::homeDirPath() + "/" + i18n("Templates") + "/";
} }
}
if (videos->isEmpty()) if (videos->isEmpty())
{
*videos = TQDir::homeDirPath() + "/" + "Videos" + "/";
if (!TQDir(*videos).exists())
{ {
*videos = TQDir::homeDirPath() + "/" + i18n("Videos") + "/"; *videos = TQDir::homeDirPath() + "/" + i18n("Videos") + "/";
} }
} }
}
static void checkAndCreateXdgFolder(const TQString &folder, const TQString &path, TDEConfig *config) static void checkAndCreateXdgFolder(const TQString &folder, const TQString &path, TDEConfig *config)
{ {

Loading…
Cancel
Save