ctkXnatSettings.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) University College London,
  4. Centre for Medical Image Computing
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. =============================================================================*/
  15. #include "ctkXnatSettings.h"
  16. #include <QDir>
  17. #include <QFileInfo>
  18. #include <QUuid>
  19. #include "ctkXnatLoginProfile.h"
  20. ctkXnatSettings::ctkXnatSettings()
  21. {
  22. }
  23. ctkXnatSettings::~ctkXnatSettings()
  24. {
  25. }
  26. QString ctkXnatSettings::getWorkSubdirectory() const
  27. {
  28. // set work directory name
  29. QDir workDir;
  30. QString workDirName = getDefaultWorkDirectory();
  31. if ( !workDirName.isEmpty() )
  32. {
  33. workDir = QDir(workDirName);
  34. }
  35. // generate random name for subdirectory
  36. QString subdir = QUuid::createUuid().toString();
  37. // create subdirectory in work directory
  38. bool subdirCreated = workDir.mkdir(subdir);
  39. // check whether subdirectory was created
  40. if ( !subdirCreated )
  41. {
  42. // display error message
  43. return QString();
  44. }
  45. // return full path of subdirectory
  46. return QFileInfo(workDir, subdir).absoluteFilePath();
  47. }