| 123 | } |
| 124 | |
| 125 | std::string |
| 126 | GetPersistentStoragePath(CoreBundleContext* ctx, std::string const& leafDir, bool create) |
| 127 | { |
| 128 | // See if we have a storage directory |
| 129 | std::string const fwdir(GetFrameworkDir(ctx)); |
| 130 | if (fwdir.empty()) |
| 131 | { |
| 132 | return fwdir; |
| 133 | } |
| 134 | std::string const dir = util::GetAbsolute(fwdir, ctx->workingDir) + util::DIR_SEP + leafDir; |
| 135 | if (!dir.empty()) |
| 136 | { |
| 137 | if (util::Exists(dir)) |
| 138 | { |
| 139 | if (!util::IsDirectory(dir)) |
| 140 | { |
| 141 | throw std::runtime_error("Not a directory: " + dir); |
| 142 | } |
| 143 | } |
| 144 | else |
| 145 | { |
| 146 | if (create) |
| 147 | { |
| 148 | try |
| 149 | { |
| 150 | util::MakePath(dir); |
| 151 | } |
| 152 | catch (std::exception const& e) |
| 153 | { |
| 154 | throw std::runtime_error("Cannot create directory: " + dir + " (" + e.what() + ")"); |
| 155 | } |
| 156 | } |
| 157 | } |
| 158 | } |
| 159 | return dir; |
| 160 | } |
| 161 | |
| 162 | void |
| 163 | TerminateForDebug(std::exception_ptr const ex) |
no test coverage detected