MCPcopy Create free account
hub / github.com/OpenFOAM/OpenFOAM-dev / fileNameComponents

Function fileNameComponents

src/OpenFOAM/db/IOobject/IOobject.C:105–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
104
105bool Foam::IOobject::fileNameComponents
106(
107 const fileName& path,
108 fileName& instance,
109 fileName& local,
110 word& name
111)
112{
113 instance.clear();
114 local.clear();
115 name.clear();
116
117 // called with directory
118 if (isDir(path))
119 {
120 WarningInFunction
121 << " called with directory: " << path << endl;
122
123 return false;
124 }
125
126 if (path.isAbsolute())
127 {
128 string::size_type last = path.rfind('/');
129 instance = path.substr(0, last);
130
131 // Check afterwards
132 name.string::operator=(path.substr(last+1));
133 }
134 else
135 {
136 string::size_type first = path.find('/');
137
138 if (first == string::npos)
139 {
140 // no '/' found - no instance or local
141
142 // check afterwards
143 name.string::operator=(path);
144 }
145 else
146 {
147 instance = path.substr(0, first);
148
149 string::size_type last = path.rfind('/');
150 if (last > first)
151 {
152 // with local
153 local = path.substr(first+1, last-first-1);
154 }
155
156 // check afterwards
157 name.string::operator=(path.substr(last+1));
158 }
159 }
160
161
162 // Check for valid (and stripped) name, regardless of the debug level

Callers 2

mainFunction · 0.85
IOobject.CFile · 0.85

Calls 3

isDirFunction · 0.50
clearMethod · 0.45
emptyMethod · 0.45

Tested by 1

mainFunction · 0.68