Leviathan  0.8.0.0
Leviathan game engine
MimeTypes.cpp
Go to the documentation of this file.
1 // ------------------------------------ //
2 #include "MimeTypes.h"
3 
5 
6 using namespace Leviathan;
7 // ------------------------------------ //
8 DLLEXPORT std::string_view Leviathan::GetMimeTypeFromPath(const std::string_view& path)
9 {
10  const auto extension = StringOperations::GetExtension(path);
11 
12  if(extension == "js" || extension == "mjs")
13  return "application/javascript";
14  if(extension == "txt")
15  return "text/plain";
16  if(extension == "png")
17  return "image/png";
18  if(extension == "jpeg" || extension == "jpg")
19  return "image/jpeg";
20  if(extension == "gif")
21  return "image/gif";
22  if(extension == "svg")
23  return "image/svg+xml";
24  if(extension == "ogg" || extension == "opus")
25  return "audio/ogg";
26  if(extension == "css")
27  return "text/css";
28  if(extension == "html")
29  return "text/html";
30  if(extension == "json")
31  return "application/json";
32  if(extension == "xml")
33  return "application/xml";
34  if(extension == "mpg")
35  return "audio/mpeg";
36  if(extension == "xml")
37  return "text/xml";
38  if(extension == "csv")
39  return "text/csv";
40  if(extension == "mkv")
41  return "video/x-matroska";
42  if(extension == "webm")
43  return "video/webm";
44  if(extension == "mp4" || extension == "mpg4" || extension == "m4v")
45  return "video/mp4";
46 
47  // Didn't match anything so this is just a guess
48  return "text/plain";
49 }
static const StringTypeN GetExtension(const StringTypeN &filepath)
DLLEXPORT std::string_view GetMimeTypeFromPath(const std::string_view &path)
This returns a mime type based on the file extension.
Definition: MimeTypes.cpp:8
#define DLLEXPORT
Definition: Include.h:84
The access mask controls which registered functions and classes a script sees.
Definition: GameModule.h:12