diff --git a/src/OpenFOAM/primitives/strings/fileName/fileName.C b/src/OpenFOAM/primitives/strings/fileName/fileName.C index 3f24ca7426029a2f48ed7f550c8d2428654ba4b2..965f53edf4f39a7742d12f77943aea4037e2f70a 100644 --- a/src/OpenFOAM/primitives/strings/fileName/fileName.C +++ b/src/OpenFOAM/primitives/strings/fileName/fileName.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -60,6 +60,20 @@ bool Foam::fileName::isAbsolute() const } +Foam::fileName& Foam::fileName::toAbsolute() +{ + fileName& f = *this; + + if (!f.isAbsolute()) + { + f = cwd()/f; + f.clean(); + } + + return f; +} + + // // * remove repeated slashes // /abc////def --> /abc/def diff --git a/src/OpenFOAM/primitives/strings/fileName/fileName.H b/src/OpenFOAM/primitives/strings/fileName/fileName.H index 3e97853a1f67598aa6daec5c8c17ba6995aead5e..d6e9684a7a77fd16efc12f7ae8bb628a26df6b1e 100644 --- a/src/OpenFOAM/primitives/strings/fileName/fileName.H +++ b/src/OpenFOAM/primitives/strings/fileName/fileName.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -141,11 +141,14 @@ public: // Interrogation - //- Return the file type: FILE, DIRECTORY or UNDEFINED - Type type() const; + //- Return the file type: FILE, DIRECTORY or UNDEFINED + Type type() const; - //- Return true if file name is absolute - bool isAbsolute() const; + //- Return true if file name is absolute + bool isAbsolute() const; + + //- Convert from relative to absolute + fileName& toAbsolute(); // Decomposition