MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / getTypeByFileName

Method getTypeByFileName

src/openms/source/FORMAT/FileHandler.cpp:53–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51 }
52
53 FileTypes::Type FileHandler::getTypeByFileName(const String& filename)
54 {
55 String basename = File::basename(filename), tmp;
56 // special rules for "double extensions":
57 if (basename.hasSuffix(".pep.xml"))
58 {
59 return FileTypes::PEPXML;
60 }
61 if (basename.hasSuffix(".prot.xml"))
62 {
63 return FileTypes::PROTXML;
64 }
65 if (basename.hasSuffix(".xquest.xml"))
66 {
67 return FileTypes::XQUESTXML;
68 }
69 if (basename.hasSuffix(".spec.xml"))
70 {
71 return FileTypes::SPECXML;
72 }
73 try
74 {
75 tmp = basename.suffix('.');
76 }
77 // no '.' => unknown type
78 catch (Exception::ElementNotFound&)
79 {
80 // last chance, Bruker fid file
81 if (basename == "fid")
82 {
83 return FileTypes::XMASS;
84 }
85 return FileTypes::UNKNOWN;
86 }
87 tmp.toUpper();
88 if (tmp == "BZ2" || tmp == "GZ") // todo ZIP (not supported yet): || tmp == "ZIP"
89 {
90 // do not use getTypeByContent() here, as this is deadly for output files!
91 return getTypeByFileName(filename.prefix(filename.size() - tmp.size() - 1)); // check name without compression suffix (e.g. bla.mzML.gz --> bla.mzML)
92 }
93
94 return FileTypes::nameToType(tmp);
95 }
96
97 bool FileHandler::hasValidExtension(const String& filename, const FileTypes::Type type)
98 {

Callers 11

main_Method · 0.80
main_Method · 0.80
main_Method · 0.80
main_Method · 0.80
main_Method · 0.80
main_Method · 0.80
main_Method · 0.80
main_Method · 0.80
main_Method · 0.80
parseParameters_Method · 0.80

Calls 5

toUpperMethod · 0.80
prefixMethod · 0.80
hasSuffixMethod · 0.45
suffixMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected