Mercurial > hg > easaier-soundaccess
changeset 12:e612e4012ca8
add connection setting information reading and saving
author | lbajardsilogic |
---|---|
date | Fri, 11 May 2007 15:42:57 +0000 |
parents | f1602cb4cd0b |
children | 7a9e35f51c7a |
files | base/TempDirectory.cpp base/TempDirectory.h |
diffstat | 2 files changed, 38 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/base/TempDirectory.cpp Fri May 11 15:42:33 2007 +0000 +++ b/base/TempDirectory.cpp Fri May 11 15:42:57 2007 +0000 @@ -52,38 +52,50 @@ cleanupDirectory(""); } +QString +TempDirectory::getDir() +{ + QMutexLocker locker(&m_mutex); + + if (m_tmpdir != "") return m_tmpdir; + + QString svDirBase = ".easaier"; + QString svDir = QDir::home().filePath(svDirBase); + if (!QFileInfo(svDir).exists()) { + if (!QDir::home().mkdir(svDirBase)) { + throw DirectoryCreationFailed(QString("%1 directory in $HOME") + .arg(svDirBase)); + } + } else if (!QFileInfo(svDir).isDir()) { + throw DirectoryCreationFailed(QString("$HOME/%1 is not a directory") + .arg(svDirBase)); + } + + cleanupAbandonedDirectories(svDir); + + return svDir; +} + QString TempDirectory::getPath() { - QMutexLocker locker(&m_mutex); - if (m_tmpdir != "") return m_tmpdir; - QSettings settings; - settings.beginGroup("TempDirectory"); - QString svDirParent = settings.value("create-in", "$HOME").toString(); - settings.endGroup(); - - svDirParent.replace("$HOME", QDir::home().absolutePath()); - - QString svDirBase = ".sv1"; - QString svDir = QDir(svDirParent).filePath(svDirBase); - if (!QFileInfo(svDir).exists()) { - if (!QDir(svDirParent).mkdir(svDirBase)) { - throw DirectoryCreationFailed(QString("%1 directory in %2") - .arg(svDirBase).arg(svDirParent)); - } - } else if (!QFileInfo(svDir).isDir()) { - throw DirectoryCreationFailed(QString("%1/%2 is not a directory") - .arg(svDirParent).arg(svDirBase)); - } - - cleanupAbandonedDirectories(svDir); + QString svDir = getDir(); return createTempDirectoryIn(svDir); } QString +TempDirectory::getConfigPath() +{ + QString configPath = getDir(); + configPath.append("/config.xml"); + + return configPath; +} + +QString TempDirectory::createTempDirectoryIn(QString dir) { // Entered with mutex held.
--- a/base/TempDirectory.h Fri May 11 15:42:33 2007 +0000 +++ b/base/TempDirectory.h Fri May 11 15:42:57 2007 +0000 @@ -52,6 +52,9 @@ */ QString getSubDirectoryPath(QString subdir); + QString getDir(); + QString getConfigPath(); + /** * Delete the temporary directory (before exiting). */ @@ -68,6 +71,7 @@ QMutex m_mutex; static TempDirectory *m_instance; + };