1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 17:58:12 +00:00
serenity/AK/FileSystemPath.h
Andreas Kling 5ba2dba392 FileSystemPath: Add a has_extension() helper.
This code:

    if (path.string().to_lowercase().ends_with(".foo"))

Can now be written as:

    if (path.has_extension(".foo"))
2019-05-27 01:53:42 +02:00

32 lines
614 B
C++

#pragma once
#include "AKString.h"
namespace AK {
class FileSystemPath {
public:
FileSystemPath() { }
explicit FileSystemPath(const String&);
bool is_valid() const { return m_is_valid; }
String string() const { return m_string; }
String basename() const { return m_basename; }
const Vector<String>& parts() const { return m_parts; }
bool has_extension(StringView) const;
private:
bool canonicalize(bool resolve_symbolic_links = false);
Vector<String> m_parts;
String m_string;
String m_basename;
bool m_is_valid { false };
};
};
using AK::FileSystemPath;