| 86 | // ---------------------------------------------------------------------------------------- |
| 87 | |
| 88 | void create_directory ( |
| 89 | const std::string& dir |
| 90 | ) |
| 91 | { |
| 92 | if (mkdir(dir.c_str(),0777)) |
| 93 | { |
| 94 | // an error has occurred |
| 95 | if (errno == EEXIST) |
| 96 | { |
| 97 | struct stat buffer; |
| 98 | // now check that this is actually a valid directory |
| 99 | if (::stat(dir.c_str(),&buffer)) |
| 100 | { |
| 101 | // the directory was not found |
| 102 | throw dir_create_error(dir); |
| 103 | } |
| 104 | else if (S_ISDIR(buffer.st_mode) == 0) |
| 105 | { |
| 106 | // It is not a directory |
| 107 | throw dir_create_error(dir); |
| 108 | } |
| 109 | } |
| 110 | else |
| 111 | { |
| 112 | throw dir_create_error(dir); |
| 113 | } |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | // ---------------------------------------------------------------------------------------- |
| 118 | } |
no test coverage detected