diff options
author | lsurn <lsurn@yandex-team.ru> | 2022-02-10 16:49:33 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:33 +0300 |
commit | 45e70bb2432018a4704845621cd9ddd2ceab6ffb (patch) | |
tree | a152f2e39b9786afe16c2a9230f7c4b12a59e4ee /library/cpp/mime | |
parent | 47a7e7b29636bfb2deb1df5f92363b3c75229c95 (diff) | |
download | ydb-45e70bb2432018a4704845621cd9ddd2ceab6ffb.tar.gz |
Restoring authorship annotation for <lsurn@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/mime')
-rw-r--r-- | library/cpp/mime/types/mime.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/library/cpp/mime/types/mime.cpp b/library/cpp/mime/types/mime.cpp index 706d776b24..84681d9e4d 100644 --- a/library/cpp/mime/types/mime.cpp +++ b/library/cpp/mime/types/mime.cpp @@ -8,10 +8,10 @@ #include <cctype> -/* +/* * MIME types - */ - + */ + class TMimeTypes { // Constructor public: @@ -165,29 +165,29 @@ const char* TMimeTypes::StrByMime(MimeTypes mime) const { } const char* mimetypeByExt(const char* fname, const char* check_ext) { - const char* ext_p; + const char* ext_p; if (fname == nullptr || *fname == 0 || (ext_p = strrchr(fname, '.')) == nullptr || strlen(ext_p) - 1 > TMimeTypes::MAX_EXT_LEN) { return nullptr; - } - + } + char ext[TMimeTypes::MAX_EXT_LEN + 1]; - size_t i; - ext_p++; + size_t i; + ext_p++; for (i = 0; i < TMimeTypes::MAX_EXT_LEN && ext_p[i]; i++) ext[i] = (char)tolower(ext_p[i]); - ext[i] = 0; - + ext[i] = 0; + if (check_ext != nullptr) { - if (strcmp(ext, check_ext) == 0) - return check_ext; - else + if (strcmp(ext, check_ext) == 0) + return check_ext; + else return nullptr; - } - + } + return Singleton<TMimeTypes>()->StrByExt(ext); -} - +} + MimeTypes mimeByStr(const char* mimeStr) { return Singleton<TMimeTypes>()->MimeByStr(mimeStr); } |