Create a file (may be on a supported remote filesystem). \param path Path to file to create. \param asBinary Whether the file should be written in binary mode. \return Pointer to the created stream, or NULL. */
| 283 | \return Pointer to the created stream, or NULL. |
| 284 | */ |
| 285 | std::ostream *createFile(const std::string& path, bool asBinary) |
| 286 | { |
| 287 | ostream *ofs(nullptr); |
| 288 | |
| 289 | if (isRemote(path)) |
| 290 | { |
| 291 | arbiter::Arbiter a; |
| 292 | if (!a.hasDriver(path)) |
| 293 | return ofs; |
| 294 | try |
| 295 | { |
| 296 | ofs = new ArbiterOutStream(tempFilename(path), path, |
| 297 | asBinary ? ios::out | ios::binary : ios::out); |
| 298 | } |
| 299 | catch (arbiter::ArbiterError&) |
| 300 | {} |
| 301 | if (ofs && !ofs->good()) |
| 302 | { |
| 303 | delete ofs; |
| 304 | ofs = nullptr; |
| 305 | } |
| 306 | } |
| 307 | else |
| 308 | ofs = FileUtils::createFile(path, asBinary); |
| 309 | return ofs; |
| 310 | } |
| 311 | |
| 312 | |
| 313 | /** |