mirror of
https://github.com/tdlight-team/tdlight-telegram-bot-api.git
synced 2025-01-23 02:07:35 +01:00
Automatically detect whether colon can be used in a directory name.
This commit is contained in:
parent
08a92a2347
commit
badeb9a7f0
@ -3456,13 +3456,13 @@ void Client::start_up() {
|
||||
set_tag(bot_token_id_);
|
||||
|
||||
auto suff = bot_token_with_dc_ + TD_DIR_SLASH;
|
||||
#if TD_PORT_WINDOWS
|
||||
for (auto &c : suff) {
|
||||
if (c == ':') {
|
||||
c = '~';
|
||||
if (!parameters_->allow_colon_in_filenames_) {
|
||||
for (auto &c : suff) {
|
||||
if (c == ':') {
|
||||
c = '~';
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
dir_ = parameters_->working_directory_ + suff;
|
||||
|
||||
class TdCallback : public td::TdCallback {
|
||||
|
@ -55,6 +55,7 @@ struct SharedData {
|
||||
|
||||
struct ClientParameters {
|
||||
td::string working_directory_;
|
||||
bool allow_colon_in_filenames_ = true;
|
||||
|
||||
bool local_mode_ = false;
|
||||
|
||||
|
@ -382,6 +382,17 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
r_temp_file.ok_ref().first.close();
|
||||
td::unlink(r_temp_file.ok().second).ensure();
|
||||
|
||||
auto r_temp_dir = td::mkdtemp(working_directory, "1:a");
|
||||
if (r_temp_dir.is_error()) {
|
||||
parameters->allow_colon_in_filenames_ = false;
|
||||
r_temp_dir = td::mkdtemp(working_directory, "1~a");
|
||||
if (r_temp_dir.is_error()) {
|
||||
return td::Status::Error(PSLICE() << "Can't create directories in the directory \"" << working_directory
|
||||
<< "\". Use --dir option to specify a writable working directory");
|
||||
}
|
||||
}
|
||||
td::rmdir(r_temp_dir.ok()).ensure();
|
||||
}
|
||||
|
||||
if (!temporary_directory.empty()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user