| 419 | |
| 420 | template <typename Dtype> |
| 421 | void Solver<Dtype>::CheckSnapshotWritePermissions() { |
| 422 | if (Caffe::root_solver() && param_.snapshot()) { |
| 423 | CHECK(param_.has_snapshot_prefix()) |
| 424 | << "In solver params, snapshot is specified but snapshot_prefix is not"; |
| 425 | string probe_filename = SnapshotFilename(".tempfile"); |
| 426 | std::ofstream probe_ofs(probe_filename.c_str()); |
| 427 | if (probe_ofs.good()) { |
| 428 | probe_ofs.close(); |
| 429 | std::remove(probe_filename.c_str()); |
| 430 | } else { |
| 431 | LOG(FATAL) << "Cannot write to snapshot prefix '" |
| 432 | << param_.snapshot_prefix() << "'. Make sure " |
| 433 | << "that the directory exists and is writeable."; |
| 434 | } |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | template <typename Dtype> |
| 439 | string Solver<Dtype>::SnapshotFilename(const string extension) { |
nothing calls this directly
no outgoing calls
no test coverage detected