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
\\ / 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

View File

@ -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