diff options
author | Michele Calgaro <[email protected]> | 2020-01-29 23:33:37 +0900 |
---|---|---|
committer | Michele Calgaro <[email protected]> | 2020-01-30 11:36:47 +0900 |
commit | d46ec74e775617b150c3f54812e9ec203e3c727e (patch) | |
tree | 12f4c0c0d72de99a556752434cca69b630fd2cfa /tdecore | |
parent | ea1da131d3eda406c2775a9b538a3e3cbd581007 (diff) | |
download | tdelibs-d46ec74e775617b150c3f54812e9ec203e3c727e.tar.gz tdelibs-d46ec74e775617b150c3f54812e9ec203e3c727e.zip |
Make sure XDG folders are created prior to their usage.
Signed-off-by: Michele Calgaro <[email protected]>
(cherry picked from commit de79e754fa8118d34ea804d6b4fb7056b65487fd)
Diffstat (limited to 'tdecore')
-rw-r--r-- | tdecore/tdeglobalsettings.cpp | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/tdecore/tdeglobalsettings.cpp b/tdecore/tdeglobalsettings.cpp index e88902fcd..241583caf 100644 --- a/tdecore/tdeglobalsettings.cpp +++ b/tdecore/tdeglobalsettings.cpp @@ -173,6 +173,23 @@ static void readXdgUserDirs(TQString *desktop, TQString *documents, TQString *do } } +static void checkAndCreateXdgFolder(const TQString &folder, const TQString &path, TDEConfig *config) +{ + bool pathOk = true; + if (!TQDir(path).exists()) + { + if (!TDEStandardDirs::makeDir(path)) + { + pathOk = false; + } + } + + if (pathOk) + { + config->writePathEntry(folder, '"' + path + '"', true, false, false, false ); + } +} + int TDEGlobalSettings::dndEventDelay() { TDEConfigGroup g( TDEGlobal::config(), "General" ); @@ -642,12 +659,30 @@ void TDEGlobalSettings::initPaths() g.sync(); } + // Create folders if they do not exists. + TDEConfig *xdgconfig = new TDEConfig(TQDir::homeDirPath()+"/.config/user-dirs.dirs"); + checkAndCreateXdgFolder("XDG_DESKTOP_DIR", *s_desktopPath, xdgconfig); + checkAndCreateXdgFolder("XDG_DOCUMENTS_DIR", *s_documentPath, xdgconfig); + checkAndCreateXdgFolder("XDG_DOWNLOAD_DIR", *s_downloadPath, xdgconfig); + checkAndCreateXdgFolder("XDG_MUSIC_DIR", *s_musicPath, xdgconfig); + checkAndCreateXdgFolder("XDG_PICTURES_DIR", *s_picturesPath, xdgconfig); + checkAndCreateXdgFolder("XDG_PUBLICSHARE_DIR", *s_publicSharePath, xdgconfig); + checkAndCreateXdgFolder("XDG_TEMPLATES_DIR", *s_templatesPath, xdgconfig); + checkAndCreateXdgFolder("XDG_VIDEOS_DIR", *s_videosPath, xdgconfig); + xdgconfig->sync(); + // Autostart Path *s_autostartPath = TDEGlobal::dirs()->localtdedir() + "Autostart/"; *s_autostartPath = g.readPathEntry( "Autostart" , *s_autostartPath); *s_autostartPath = TQDir::cleanDirPath( *s_autostartPath ); - if ( !s_autostartPath->endsWith("/") ) + if (!s_autostartPath->endsWith("/")) + { s_autostartPath->append('/'); + } + if (!TQDir(*s_autostartPath).exists()) + { + TDEStandardDirs::makeDir(*s_autostartPath); + } // Make sure this app gets the notifications about those paths if (kapp) |