comparison Core/Toolbox.cpp @ 1648:a0a4fa28624c

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 25 Sep 2015 11:33:55 +0200
parents 4e56b5a206b7
children 3727a09e7b53
comparison
equal deleted inserted replaced
1647:fe458dde986e 1648:a0a4fa28624c
525 void Toolbox::DecodeBase64(std::string& result, 525 void Toolbox::DecodeBase64(std::string& result,
526 const std::string& data) 526 const std::string& data)
527 { 527 {
528 result = base64_decode(data); 528 result = base64_decode(data);
529 } 529 }
530
531
532 # if BOOST_HAS_REGEX == 1
533 void Toolbox::DecodeDataUriScheme(std::string& mime,
534 std::string& content,
535 const std::string& source)
536 {
537 boost::regex pattern("data:([^;]+);base64,([a-zA-Z0-9=+/]*)",
538 boost::regex::icase /* case insensitive search */);
539
540 boost::cmatch what;
541 if (regex_match(source.c_str(), what, pattern))
542 {
543 mime = what[1];
544 DecodeBase64(content, what[2]);
545 }
546 else
547 {
548 throw OrthancException(ErrorCode_BadFileFormat);
549 }
550 }
551 # endif
552
530 #endif 553 #endif
531 554
532 555
533 556
534 #if defined(_WIN32) 557 #if defined(_WIN32)
1007 1030
1008 result.push_back(currentItem); 1031 result.push_back(currentItem);
1009 } 1032 }
1010 1033
1011 1034
1012 #if BOOST_HAS_REGEX == 1
1013 void Toolbox::DecodeDataUriScheme(std::string& mime,
1014 std::string& content,
1015 const std::string& source)
1016 {
1017 boost::regex pattern("data:([^;]+);base64,([a-zA-Z0-9=+/]*)",
1018 boost::regex::icase /* case insensitive search */);
1019
1020 boost::cmatch what;
1021 if (regex_match(source.c_str(), what, pattern))
1022 {
1023 mime = what[1];
1024 DecodeBase64(content, what[2]);
1025 }
1026 else
1027 {
1028 throw OrthancException(ErrorCode_BadFileFormat);
1029 }
1030 }
1031 #endif
1032
1033
1034 void Toolbox::MakeDirectory(const std::string& path) 1035 void Toolbox::MakeDirectory(const std::string& path)
1035 { 1036 {
1036 if (boost::filesystem::exists(path)) 1037 if (boost::filesystem::exists(path))
1037 { 1038 {
1038 if (!boost::filesystem::is_directory(path)) 1039 if (!boost::filesystem::is_directory(path))