Mercurial > hg > orthanc
comparison Core/SystemToolbox.cpp @ 2908:9d277f8ad698
new enumeration: MimeType
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 30 Oct 2018 16:16:07 +0100 |
parents | 2a504fef4ed7 |
children | ad0e7def3338 |
comparison
equal
deleted
inserted
replaced
2907:0204af4ece6a | 2908:9d277f8ad698 |
---|---|
578 return threads; | 578 return threads; |
579 } | 579 } |
580 } | 580 } |
581 | 581 |
582 | 582 |
583 std::string SystemToolbox::AutodetectMimeType(const std::string& path) | 583 MimeType SystemToolbox::AutodetectMimeType(const std::string& path) |
584 { | 584 { |
585 std::string extension = boost::filesystem::extension(path); | 585 std::string extension = boost::filesystem::extension(path); |
586 Toolbox::ToLowerCase(extension); | 586 Toolbox::ToLowerCase(extension); |
587 | 587 |
588 // http://en.wikipedia.org/wiki/Mime_types | 588 // http://en.wikipedia.org/wiki/Mime_types |
589 // Text types | 589 // Text types |
590 if (extension == ".txt") | 590 if (extension == ".txt") |
591 { | 591 { |
592 return MIME_PLAIN_TEXT; | 592 return MimeType_PlainText; |
593 } | 593 } |
594 else if (extension == ".html") | 594 else if (extension == ".html") |
595 { | 595 { |
596 return "text/html"; | 596 return MimeType_Html; |
597 } | 597 } |
598 else if (extension == ".xml") | 598 else if (extension == ".xml") |
599 { | 599 { |
600 return MIME_XML; | 600 return MimeType_Xml; |
601 } | 601 } |
602 else if (extension == ".css") | 602 else if (extension == ".css") |
603 { | 603 { |
604 return "text/css"; | 604 return MimeType_Css; |
605 } | 605 } |
606 | 606 |
607 // Application types | 607 // Application types |
608 else if (extension == ".js") | 608 else if (extension == ".js") |
609 { | 609 { |
610 return "application/javascript"; | 610 return MimeType_JavaScript; |
611 } | 611 } |
612 else if (extension == ".json") | 612 else if (extension == ".json") |
613 { | 613 { |
614 return MIME_JSON; | 614 return MimeType_Json; |
615 } | 615 } |
616 else if (extension == ".pdf") | 616 else if (extension == ".pdf") |
617 { | 617 { |
618 return MIME_PDF; | 618 return MimeType_Pdf; |
619 } | 619 } |
620 else if (extension == ".wasm") | 620 else if (extension == ".wasm") |
621 { | 621 { |
622 return "application/wasm"; | 622 return MimeType_WebAssembly; |
623 } | 623 } |
624 | 624 |
625 // Images types | 625 // Images types |
626 else if (extension == ".jpg" || | 626 else if (extension == ".jpg" || |
627 extension == ".jpeg") | 627 extension == ".jpeg") |
628 { | 628 { |
629 return MIME_JPEG; | 629 return MimeType_Jpeg; |
630 } | 630 } |
631 else if (extension == ".gif") | 631 else if (extension == ".gif") |
632 { | 632 { |
633 return "image/gif"; | 633 return MimeType_Gif; |
634 } | 634 } |
635 else if (extension == ".png") | 635 else if (extension == ".png") |
636 { | 636 { |
637 return MIME_PNG; | 637 return MimeType_Png; |
638 } | 638 } |
639 else if (extension == ".pam") | 639 else if (extension == ".pam") |
640 { | 640 { |
641 return MIME_PAM; | 641 return MimeType_Pam; |
642 } | 642 } |
643 else | 643 else |
644 { | 644 { |
645 return ""; | 645 return MimeType_Binary; |
646 } | 646 } |
647 } | 647 } |
648 } | 648 } |