25#ifndef __JOIN_FILESYSTEM_HPP__
26#define __JOIN_FILESYSTEM_HPP__
38 __inline__ std::string
base (
const std::string& filepath)
40 size_t pos = filepath.rfind (
"/");
42 if (pos == std::string::npos)
45 return filepath.substr (0, pos + 1);
53 __inline__ std::string
filename (
const std::string& filepath)
55 size_t pos = filepath.rfind (
"/");
57 if (pos == std::string::npos)
60 return filepath.substr (pos + 1);
68 __inline__ std::string
extension (
const std::string& filepath)
70 size_t pos = filepath.rfind (
".");
72 if (pos == std::string::npos)
75 return filepath.substr (pos + 1);
83 __inline__ std::string
mime (
const std::string& filepath)
89 else if (suffix ==
"html")
91 else if (suffix ==
"css")
93 else if (suffix ==
"less")
95 else if (suffix ==
"js")
96 mime =
"application/javascript";
97 else if (suffix ==
"xml")
99 else if (suffix ==
"json")
100 mime =
"application/json";
101 else if (suffix ==
"txt")
103 else if (suffix ==
"properties")
104 mime =
"text/x-java-properties";
105 else if (suffix ==
"jpg")
107 else if (suffix ==
"jpeg")
109 else if (suffix ==
"png")
111 else if (suffix ==
"bmp")
113 else if (suffix ==
"gif")
115 else if (suffix ==
"jpe")
117 else if (suffix ==
"xbm")
119 else if (suffix ==
"tiff")
121 else if (suffix ==
"tif")
123 else if (suffix ==
"ico")
124 mime =
"image/x-icon";
125 else if (suffix ==
"svg")
126 mime =
"image/svg+xml";
127 else if (suffix ==
"pdf")
128 mime =
"application/pdf";
129 else if (suffix ==
"mp3")
131 else if (suffix ==
"mp4")
133 else if (suffix ==
"zip")
134 mime =
"application/zip";
135 else if (suffix ==
"bz2")
136 mime =
"application/x-bzip";
137 else if (suffix ==
"tbz2")
138 mime =
"application/x-bzip";
139 else if (suffix ==
"tb2")
140 mime =
"application/x-bzip";
141 else if (suffix ==
"gz")
142 mime =
"application/x-gzip";
143 else if (suffix ==
"gzip")
144 mime =
"application/x-gzip";
145 else if (suffix ==
"tar")
146 mime =
"application/x-tar";
147 else if (suffix ==
"rar")
148 mime =
"application/x-rar-compressed";
149 else if (suffix ==
"tpl")
150 mime =
"application/vnd.groove-tool-template";
151 else if (suffix ==
"woff")
152 mime =
"application/font-woff";
153 else if (suffix ==
"woff2")
154 mime =
"application/font-woff2";
156 mime =
"application/octet-stream";
Definition acceptor.hpp:32
__inline__ std::string extension(const std::string &filepath)
get extension of the file specified.
Definition filesystem.hpp:68
__inline__ std::string filename(const std::string &filepath)
get file name of the specified file.
Definition filesystem.hpp:53
__inline__ std::string mime(const std::string &filepath)
get mime type of the specified file.
Definition filesystem.hpp:83
__inline__ std::string base(const std::string &filepath)
get base path of the specified file.
Definition filesystem.hpp:38