Add archives.h
This commit is contained in:
parent
21c7186b81
commit
d8cb560f68
51
main.cpp
51
main.cpp
@ -7,7 +7,8 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#ifndef NO_MIME
|
#ifndef NO_MIME
|
||||||
#include <magic.h>
|
#include <magic.h> // Did you remember to run ./configure?
|
||||||
|
#include "archives.h" // Run make nomime
|
||||||
#endif
|
#endif
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -60,53 +61,10 @@ bool starts_with(const std::string& prefix, const std::string& string) {
|
|||||||
return string.rfind(prefix, 0) == 0;
|
return string.rfind(prefix, 0) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NO_MIME
|
||||||
bool is_archive(const std::string& mime_type)
|
bool is_archive(const std::string& mime_type)
|
||||||
{
|
{
|
||||||
const std::string archives[] = {
|
const std::string archives[] = ARCHIVES;
|
||||||
"application/x-archive",
|
|
||||||
"application/x-cpio",
|
|
||||||
"application/x-shar",
|
|
||||||
"application/x-iso9660-image",
|
|
||||||
"application/x-sbx",
|
|
||||||
"application/x-tar",
|
|
||||||
"application/x-brotli",
|
|
||||||
"application/x-bzip2",
|
|
||||||
"application/vnd.genozip",
|
|
||||||
"application/gzip",
|
|
||||||
"application/x-lzip",
|
|
||||||
"application/x-lzma",
|
|
||||||
"application/x-lzop",
|
|
||||||
"application/x-snappy-framed",
|
|
||||||
"application/x-xz",
|
|
||||||
"application/x-compress",
|
|
||||||
"application/x-compress",
|
|
||||||
"application/zstd",
|
|
||||||
"application/x-7z-compressed",
|
|
||||||
"application/x-ace-compressed",
|
|
||||||
"application/x-astrotite-afa",
|
|
||||||
"application/x-alz-compressed",
|
|
||||||
"application/vnd.android.package-archive",
|
|
||||||
"application/x-freearc",
|
|
||||||
"application/x-arj",
|
|
||||||
"application/x-b1",
|
|
||||||
"application/vnd.ms-cab-compressed",
|
|
||||||
"application/x-cfs-compressed",
|
|
||||||
"application/x-dar",
|
|
||||||
"application/x-dgc-compressed",
|
|
||||||
"application/x-apple-diskimage",
|
|
||||||
"application/x-gca-compressed",
|
|
||||||
"application/java-archive",
|
|
||||||
"application/x-lzh",
|
|
||||||
"application/x-lzx",
|
|
||||||
"application/x-rar-compressed",
|
|
||||||
"application/x-stuffit",
|
|
||||||
"application/x-stuffitx",
|
|
||||||
"application/x-gtar",
|
|
||||||
"application/x-ms-wim",
|
|
||||||
"application/x-xar",
|
|
||||||
"application/zip",
|
|
||||||
"application/x-zoo"
|
|
||||||
};
|
|
||||||
int len = sizeof(archives)/sizeof(archives[0]);
|
int len = sizeof(archives)/sizeof(archives[0]);
|
||||||
|
|
||||||
for(int i = 0; i < len; ++i)
|
for(int i = 0; i < len; ++i)
|
||||||
@ -118,6 +76,7 @@ bool is_archive(const std::string& mime_type)
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
std::string get_name_from_filetype(const enum FileType fs)
|
std::string get_name_from_filetype(const enum FileType fs)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user