More robust mkpath.
GitOrigin-RevId: 3c0417c3223dff7161f4457da8ae475f6dc8f925
This commit is contained in:
parent
67b1cce74e
commit
a3717481ed
@ -437,7 +437,7 @@ Result<unique_ptr<ReplyMarkup>> get_reply_markup(tl_object_ptr<td_api::ReplyMark
|
||||
continue;
|
||||
}
|
||||
|
||||
TRY_RESULT(current_button, get_keyboard_button(std::move(button), request_buttons_allowed))
|
||||
TRY_RESULT(current_button, get_keyboard_button(std::move(button), request_buttons_allowed));
|
||||
|
||||
row_buttons.push_back(std::move(current_button));
|
||||
row_button_count++;
|
||||
|
@ -50,11 +50,19 @@ Status set_temporary_dir(CSlice dir) {
|
||||
}
|
||||
|
||||
Status mkpath(CSlice path, int32 mode) {
|
||||
Status first_error = Status::OK();
|
||||
Status last_error = Status::OK();
|
||||
for (size_t i = 1; i < path.size(); i++) {
|
||||
if (path[i] == TD_DIR_SLASH) {
|
||||
TRY_STATUS(mkdir(path.substr(0, i).str(), mode))
|
||||
last_error = mkdir(path.substr(0, i).str(), mode);
|
||||
if (last_error.is_error() && first_error.is_ok()) {
|
||||
first_error = last_error.clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (last_error.is_error()) {
|
||||
return first_error;
|
||||
}
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user