1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
30 \*---------------------------------------------------------------------------*/
35 #include "IOstreams.H"
36 #include "OSspecific.H"
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 wrdList[1] = "hello1";
48 wrdList[2] = "hello2";
49 wrdList[3] = "hello3";
50 wrdList[4] = "hello4.hmm";
52 fileName pathName(wrdList);
54 Info<< "pathName = " << pathName << nl
55 << "pathName.name() = " << pathName.name() << nl
56 << "pathName.path() = " << pathName.path() << nl
57 << "pathName.ext() = " << pathName.ext() << endl;
59 Info<< "pathName.components() = " << pathName.components() << nl
60 << "pathName.component(2) = " << pathName.component(2) << nl
63 // try with different combination
64 // The final one should emit warnings
65 for (label start = 0; start <= wrdList.size(); ++start)
67 fileName instance, local;
70 fileName path(SubList<word>(wrdList, wrdList.size()-start, start));
71 fileName path2 = "." / path;
73 IOobject::fileNameComponents
81 Info<< "IOobject::fileNameComponents for " << path << nl
82 << " instance = " << instance << nl
83 << " local = " << local << nl
84 << " name = " << name << endl;
86 IOobject::fileNameComponents
94 Info<< "IOobject::fileNameComponents for " << path2 << nl
95 << " instance = " << instance << nl
96 << " local = " << local << nl
97 << " name = " << name << endl;
102 Info<< "\n\nfindEtcFile tests:" << nl
103 << " controlDict => " << findEtcFile("controlDict") << nl
104 << " badName => " << findEtcFile("badName") << endl;
106 Info<< "This should emit a fatal error:" << endl;
107 Info<< " badName(die) => " << findEtcFile("badName", true) << nl
110 Info<< "\nEnd" << endl;
116 // ************************************************************************* //