diff --git a/src/OpenFOAM/primitives/strings/fileName/fileName.C b/src/OpenFOAM/primitives/strings/fileName/fileName.C index e1e6a5ba30940aa7e82434ae14aed9db160f2e60..58fe305d3b3e3bee49a0687f4bc7253005c2fcb2 100644 --- a/src/OpenFOAM/primitives/strings/fileName/fileName.C +++ b/src/OpenFOAM/primitives/strings/fileName/fileName.C @@ -201,9 +201,21 @@ Foam::fileName::fileName(std::initializer_list<word> list) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::fileName::Type Foam::fileName::type(const bool followLink) const +Foam::fileName::Type Foam::fileName::type +( + bool followLink, + bool checkGzip +) const { - return ::Foam::type(*this, followLink); + Type t = ::Foam::type(*this, followLink); + + if (checkGzip && (Type::UNDEFINED == t) && size()) + { + // Also check for gzip file? + t = ::Foam::type(*this + ".gz", followLink); + } + + return t; } diff --git a/src/OpenFOAM/primitives/strings/fileName/fileName.H b/src/OpenFOAM/primitives/strings/fileName/fileName.H index e34e8a49c14d0ab6037262d6f466a874ff8d402d..0f7354d3ff9d6db80b0960c902f5e435d26d1f66 100644 --- a/src/OpenFOAM/primitives/strings/fileName/fileName.H +++ b/src/OpenFOAM/primitives/strings/fileName/fileName.H @@ -80,13 +80,13 @@ class fileName public: - //- Enumerations to handle file types and modes. + //- Enumerations to handle directory entry types. enum Type { - UNDEFINED, //!< Undefined file type. - FILE, //!< A file - DIRECTORY, //!< A directory - LINK //!< A symlink + UNDEFINED = 0, //!< Undefined type + FILE = 1, //!< A file + DIRECTORY = 2, //!< A directory + LINK = 4 //!< A symlink }; @@ -201,9 +201,13 @@ public: // Interrogation - //- Return the file type: FILE, DIRECTORY, LINK or UNDEFINED. - // LINK is only returned if followLink=false - Type type(const bool followLink = true) const; + //- Return the directory entry type: + //- UNDEFINED, FILE, DIRECTORY (or LINK). + // + // \param followLink when false it will return LINK for a symlink + // rather than following it. + // \param checkGzip add an additional test for a gzip FILE + Type type(bool followLink=true, bool checkGzip=false) const; //- Return true if string starts with a '/' inline static bool isAbsolute(const std::string& str);