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 | d8825989a7621fc7275e8cfdba16b4f699fb6359 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/mime | |
parent | 45e70bb2432018a4704845621cd9ddd2ceab6ffb (diff) | |
download | ydb-d8825989a7621fc7275e8cfdba16b4f699fb6359.tar.gz |
Restoring authorship annotation for <lsurn@yandex-team.ru>. Commit 2 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 84681d9e4d..706d776b24 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); } |