- std::string log_dir = "/tmp/vv-log";
- int err = mkdir(log_dir.c_str(), S_IRWXU | S_IRUSR | S_IWUSR | S_IRWXG | S_IRGRP | S_IWGRP | S_IRWXO | S_IROTH | S_IWOTH);
- if (err && errno != EEXIST)
- std::cout << "Error creating log directory with errno " << errno << std::endl;
+ std::string log_dir = QDir::tempPath().toStdString() + std::string("/vv-log");
+
+ if(itksys::SystemTools::FileExists(log_dir.c_str()) &&
+ !itksys::SystemTools::FileIsDirectory(log_dir.c_str())) {
+ itkGenericExceptionMacro(<< "Error creating log directory, file exists and is not a directory.");
+ }
+ else if(!itksys::SystemTools::MakeDirectory(log_dir.c_str())) {
+ itkGenericExceptionMacro(<< "Error creating log directory.");
+ }