OpenMS
Loading...
Searching...
No Matches
FileNameUtils.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Timo Sachsenberg $
6// $Authors: Marc Sturm, Timo Sachsenberg $
7// --------------------------------------------------------------------------
8
9#pragma once
10
12
13#include <cstddef>
14#include <string>
15
16namespace OpenMS
17{
28 class OPENMS_DLLAPI FileNameUtils
29 {
30 public:
35 static FileTypes::Type getTypeByFileName(const std::string& filename);
36
41 static bool hasValidExtension(const std::string& filename, FileTypes::Type type);
42
51 static FileTypes::Type compressionType(const std::string& filename);
52
56 static bool hasCompressionSuffix(const std::string& filename);
57
63 static std::string stripExtension(const std::string& filename);
64
70 static std::string swapExtension(const std::string& filename, FileTypes::Type new_type);
71
72 private:
84 static FileTypes::Type matchExtension_(const std::string& filename, size_t& ext_start);
85 };
86}
Filename-only format recognition and extension manipulation.
Definition FileNameUtils.h:29
static FileTypes::Type matchExtension_(const std::string &filename, size_t &ext_start)
Match the longest known extension at the end of filename.
static bool hasCompressionSuffix(const std::string &filename)
Does filename end in a compression suffix (.gz/.bz2/.zip)?
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.
static FileTypes::Type compressionType(const std::string &filename)
Which compression suffix does filename end in?
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Type
Actual file types enum.
Definition FileTypes.h:31