ENH: fileName - added isAbsolute function

This commit is contained in:
andy
2014-04-04 16:38:41 +01:00
committed by Andrew Heather
parent 468da226bb
commit 5d24a33c48
2 changed files with 23 additions and 6 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License 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 // * remove repeated slashes
// /abc////def --> /abc/def // /abc////def --> /abc/def

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -147,6 +147,9 @@ public:
//- Return true if file name is absolute //- Return true if file name is absolute
bool isAbsolute() const; bool isAbsolute() const;
//- Convert from relative to absolute
fileName& toAbsolute();
// Decomposition // Decomposition