| 655 | } |
| 656 | |
| 657 | Status DebugFileIO::RecursiveCreateDir(Env* env, const string& dir) { |
| 658 | if (env->FileExists(dir).ok() && env->IsDirectory(dir).ok()) { |
| 659 | // The path already exists as a directory. Return OK right away. |
| 660 | return Status::OK(); |
| 661 | } |
| 662 | |
| 663 | string parent_dir(io::Dirname(dir)); |
| 664 | if (!env->FileExists(parent_dir).ok()) { |
| 665 | // The parent path does not exist yet, create it first. |
| 666 | Status s = RecursiveCreateDir(env, parent_dir); // Recursive call |
| 667 | if (!s.ok()) { |
| 668 | return Status( |
| 669 | error::FAILED_PRECONDITION, |
| 670 | strings::StrCat("Failed to create directory ", parent_dir)); |
| 671 | } |
| 672 | } else if (env->FileExists(parent_dir).ok() && |
| 673 | !env->IsDirectory(parent_dir).ok()) { |
| 674 | // The path exists, but it is a file. |
| 675 | return Status(error::FAILED_PRECONDITION, |
| 676 | strings::StrCat("Failed to create directory ", parent_dir, |
| 677 | " because the path exists as a file ")); |
| 678 | } |
| 679 | |
| 680 | env->CreateDir(dir).IgnoreError(); |
| 681 | // Guard against potential race in creating directories by doing a check |
| 682 | // after the CreateDir call. |
| 683 | if (env->FileExists(dir).ok() && env->IsDirectory(dir).ok()) { |
| 684 | return Status::OK(); |
| 685 | } else { |
| 686 | return Status(error::ABORTED, |
| 687 | strings::StrCat("Failed to create directory ", parent_dir)); |
| 688 | } |
| 689 | } |
| 690 | |
| 691 | // Default total disk usage limit: 100 GBytes |
| 692 | const uint64 DebugFileIO::kDefaultGlobalDiskBytesLimit = 107374182400L; |
nothing calls this directly
no test coverage detected