![]() |
OpenMS
|
Filename-only format recognition and extension manipulation. More...
#include <OpenMS/FORMAT/FileNameUtils.h>
Static Public Member Functions | |
| static FileTypes::Type | getTypeByFileName (const std::string &filename) |
| Determine a file type from its name, including compression suffixes. | |
| static bool | hasValidExtension (const std::string &filename, FileTypes::Type type) |
| Accept the expected extension or an unknown extension. | |
| static FileTypes::Type | compressionType (const std::string &filename) |
Which compression suffix does filename end in? | |
| static bool | hasCompressionSuffix (const std::string &filename) |
Does filename end in a compression suffix (.gz/.bz2/.zip)? | |
| static std::string | stripExtension (const std::string &filename) |
| Remove the extension using the established FileHandler rules. | |
| static std::string | swapExtension (const std::string &filename, FileTypes::Type new_type) |
| Strip the existing extension and append the requested extension. | |
Static Private Member Functions | |
| static FileTypes::Type | matchExtension_ (const std::string &filename, size_t &ext_start) |
Match the longest known extension at the end of filename. | |
Filename-only format recognition and extension manipulation.
These operations preserve FileHandler's filename rules and never inspect file contents or require the path to exist. Extensions are resolved through the FileTypes registry, so registered aliases (e.g. '.fa' for FASTA) are recognized alongside the preferred extension. Both slash styles are recognized on every platform. FileHandler retains its existing forwarding entry points.
|
static |
Which compression suffix does filename end in?
getTypeByFileName() sees through such a suffix to the inner type, so callers that need to know whether a reader must decompress have to ask separately (see FileTypes::supportsCompressedReading, which needs this value because not every reader handles every container).
| [in] | filename | Filename to inspect. |
|
static |
Determine a file type from its name, including compression suffixes.
| [in] | filename | Filename to inspect. |
|
static |
Does filename end in a compression suffix (.gz/.bz2/.zip)?
| [in] | filename | Filename to inspect. |
|
static |
Accept the expected extension or an unknown extension.
| [in] | filename | Filename to inspect. |
| [in] | type | Expected type. |
|
staticprivate |
Match the longest known extension at the end of filename.
Every dot-delimited suffix of the basename is looked up in the FileTypes registry (preferred extensions and aliases alike) and the longest match wins, so '.pep.xml' is preferred over '.xml'. A trailing compression suffix is seen through and counted as part of the extension.
| [in] | filename | Filename to inspect. |
| [out] | ext_start | Offset of the '.' that starts the extension, or npos if the basename has no extension at all. Set even when the type is UNKNOWN, in which case it points at the last dot. |
|
static |
Remove the extension using the established FileHandler rules.
| [in] | filename | Filename whose extension should be removed. |
|
static |
Strip the existing extension and append the requested extension.
| [in] | filename | Original filename. |
| [in] | new_type | Type of the new extension. |