aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorlevlam <levlam@telegram.org>2023-06-26 06:59:19 +0300
committerlevlam <levlam@telegram.org>2023-06-26 06:59:19 +0300
commit6ce85fdc4ff95be2d698e93d9004aadf126e8c6c (patch)
tree5d5c266d3dfc1c412203f51b215128208d89c0ba
parent29ca948f09f40bc9db6232a92efa5ac44331ea28 (diff)
Remove explicit mode parameter from tl_file_utils.
-rw-r--r--td/generate/remove_documentation.cpp4
-rw-r--r--tdtl/td/tl/tl_file_utils.cpp8
-rw-r--r--tdtl/td/tl/tl_file_utils.h4
-rw-r--r--tdtl/td/tl/tl_generate.cpp6
4 files changed, 11 insertions, 11 deletions
diff --git a/td/generate/remove_documentation.cpp b/td/generate/remove_documentation.cpp
index 435a90556..7e4651414 100644
--- a/td/generate/remove_documentation.cpp
+++ b/td/generate/remove_documentation.cpp
@@ -13,9 +13,9 @@
int main(int argc, char *argv[]) {
for (int i = 1; i < argc; i++) {
std::string file_name = argv[i];
- std::string old_contents = td::tl::get_file_contents(file_name, "rb");
+ std::string old_contents = td::tl::get_file_contents(file_name);
std::string new_contents = td::tl::remove_documentation(old_contents);
- if (new_contents != old_contents && !td::tl::put_file_contents(file_name, "wb", new_contents)) {
+ if (new_contents != old_contents && !td::tl::put_file_contents(file_name, new_contents)) {
std::fprintf(stderr, "Can't write file %s\n", file_name.c_str());
std::abort();
}
diff --git a/tdtl/td/tl/tl_file_utils.cpp b/tdtl/td/tl/tl_file_utils.cpp
index 57d3c0a01..91c859d03 100644
--- a/tdtl/td/tl/tl_file_utils.cpp
+++ b/tdtl/td/tl/tl_file_utils.cpp
@@ -12,8 +12,8 @@
namespace td {
namespace tl {
-std::string get_file_contents(const std::string &file_name, const std::string &mode) {
- FILE *f = std::fopen(file_name.c_str(), mode.c_str());
+std::string get_file_contents(const std::string &file_name) {
+ FILE *f = std::fopen(file_name.c_str(), "rb");
if (f == NULL) {
return std::string();
}
@@ -44,8 +44,8 @@ std::string get_file_contents(const std::string &file_name, const std::string &m
return result;
}
-bool put_file_contents(const std::string &file_name, const std::string &mode, const std::string &contents) {
- FILE *f = std::fopen(file_name.c_str(), mode.c_str());
+bool put_file_contents(const std::string &file_name, const std::string &contents) {
+ FILE *f = std::fopen(file_name.c_str(), "wb");
if (f == NULL) {
std::fprintf(stderr, "Can't open file \"%s\"\n", file_name.c_str());
return false;
diff --git a/tdtl/td/tl/tl_file_utils.h b/tdtl/td/tl/tl_file_utils.h
index ef837f3bb..6d4cc7132 100644
--- a/tdtl/td/tl/tl_file_utils.h
+++ b/tdtl/td/tl/tl_file_utils.h
@@ -11,9 +11,9 @@
namespace td {
namespace tl {
-std::string get_file_contents(const std::string &file_name, const std::string &mode);
+std::string get_file_contents(const std::string &file_name);
-bool put_file_contents(const std::string &file_name, const std::string &mode, const std::string &contents);
+bool put_file_contents(const std::string &file_name, const std::string &contents);
std::string remove_documentation(const std::string &str);
diff --git a/tdtl/td/tl/tl_generate.cpp b/tdtl/td/tl/tl_generate.cpp
index 03dce1556..66d0dcee6 100644
--- a/tdtl/td/tl/tl_generate.cpp
+++ b/tdtl/td/tl/tl_generate.cpp
@@ -837,7 +837,7 @@ void write_tl(const tl_config &config, tl_outputer &out, const TL_writer &w) {
}
tl_config read_tl_config_from_file(const std::string &file_name) {
- std::string config = get_file_contents(file_name, "rb");
+ std::string config = get_file_contents(file_name);
if (config.empty()) {
std::fprintf(stderr, "Config file %s is empty\n", file_name.c_str());
std::abort();
@@ -856,14 +856,14 @@ bool write_tl_to_file(const tl_config &config, const std::string &file_name, con
tl_string_outputer out;
write_tl(config, out, w);
- std::string old_file_contents = get_file_contents(file_name, "rb");
+ std::string old_file_contents = get_file_contents(file_name);
if (!w.is_documentation_generated()) {
old_file_contents = remove_documentation(old_file_contents);
}
if (old_file_contents != out.get_result()) {
std::fprintf(stderr, "Write tl to file %s\n", file_name.c_str());
- return put_file_contents(file_name, "wb", out.get_result());
+ return put_file_contents(file_name, out.get_result());
}
return true;