1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2011 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/>.
28 Test some basic fileName functionality
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() << "<\n"
56 << "pathName.path() = " << pathName.path() << nl
57 << "pathName.ext() = >" << pathName.ext() << "<\n"
58 << "pathName.name(true) = >" << pathName.name(true) << "<\n";
60 Info<< "pathName.components() = " << pathName.components() << nl
61 << "pathName.component(2) = " << pathName.component(2) << nl
64 // try with different combination
65 // The final one should emit warnings
66 for (label start = 0; start <= wrdList.size(); ++start)
68 fileName instance, local;
71 fileName path(SubList<word>(wrdList, wrdList.size()-start, start));
72 fileName path2 = "."/path;
74 IOobject::fileNameComponents
82 Info<< "IOobject::fileNameComponents for " << path << nl
83 << " instance = " << instance << nl
84 << " local = " << local << nl
85 << " name = " << name << endl;
87 IOobject::fileNameComponents
95 Info<< "IOobject::fileNameComponents for " << path2 << nl
96 << " instance = " << instance << nl
97 << " local = " << local << nl
98 << " name = " << name << endl;
103 Info<< "\n\nfindEtcFile tests:" << nl
104 << " controlDict => " << findEtcFile("controlDict") << nl
105 << " badName => " << findEtcFile("badName") << endl;
107 Info<< "This should emit a fatal error:" << endl;
108 Info<< " badName(die) => " << findEtcFile("badName", true) << nl
111 Info<< "\nEnd\n" << endl;
116 // ************************************************************************* //