OpenMS
Loading...
Searching...
No Matches
FileNameUtils Class Reference

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 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.
 

Detailed Description

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. Both slash styles are recognized on every platform. FileHandler retains its existing forwarding entry points.

Member Function Documentation

◆ getTypeByFileName()

static FileTypes::Type getTypeByFileName ( const std::string &  filename)
static

Determine a file type from its name, including compression suffixes.

Parameters
[in]filenameFilename to inspect.
Returns
Recognized type, or FileTypes::UNKNOWN.

◆ hasValidExtension()

static bool hasValidExtension ( const std::string &  filename,
FileTypes::Type  type 
)
static

Accept the expected extension or an unknown extension.

Parameters
[in]filenameFilename to inspect.
[in]typeExpected type.

◆ stripExtension()

static std::string stripExtension ( const std::string &  filename)
static

Remove the extension using the established FileHandler rules.

Parameters
[in]filenameFilename whose extension should be removed.
Returns
Filename with its recognized extension removed, or the last basename suffix removed for an unknown type.

◆ swapExtension()

static std::string swapExtension ( const std::string &  filename,
FileTypes::Type  new_type 
)
static

Strip the existing extension and append the requested extension.

Parameters
[in]filenameOriginal filename.
[in]new_typeType of the new extension.
Returns
Filename with the replacement extension.