#pragma once #include "core/common.h" #include #include #include #include namespace vn { enum class AttributeEol : std::uint8_t { None = 0, Lf = 1, Crlf = 2, Cr = 3, }; enum class AttributeText : std::uint8_t { Auto = 0, Text = 1, Binary = 2, }; struct PathAttributes { bool generated = false; AttributeText text = AttributeText::Auto; AttributeEol eol = AttributeEol::None; }; class AttributeRules { public: static AttributeRules load(const fs::path& root); PathAttributes lookup(std::string_view path) const; bool changed_since(std::int64_t cache_written_ms) const; private: struct Rule { std::string pattern; bool has_slash = false; bool generated_set = false; bool generated = false; bool text_set = false; AttributeText text = AttributeText::Auto; bool eol_set = false; AttributeEol eol = AttributeEol::None; }; std::vector rules_; std::int64_t mtime_ns_ = 0; }; std::vector normalize_eol(Bytes data, AttributeEol eol); } // namespace vn