diff --git a/src/OSspecific/POSIX/POSIX.C b/src/OSspecific/POSIX/POSIX.C
index 0b9a541d9..aa76bd277 100644
--- a/src/OSspecific/POSIX/POSIX.C
+++ b/src/OSspecific/POSIX/POSIX.C
@@ -292,155 +292,6 @@ bool Foam::chDir(const fileName& dir)
}
-Foam::fileNameList Foam::findEtcFiles
-(
- const fileName& name,
- bool mandatory,
- bool findFirst
-)
-{
- fileNameList results;
-
- // Search for user files in
- // * ~/.OpenFOAM/VERSION
- // * ~/.OpenFOAM
- //
- fileName searchDir = home()/".OpenFOAM";
- if (isDir(searchDir))
- {
- fileName fullName = searchDir/FOAMversion/name;
- if (isFile(fullName))
- {
- results.append(fullName);
- if (findFirst)
- {
- return results;
- }
- }
-
- fullName = searchDir/name;
- if (isFile(fullName))
- {
- results.append(fullName);
- if (findFirst)
- {
- return results;
- }
- }
- }
-
- // Search for group (site) files in
- // * $WM_PROJECT_SITE/VERSION
- // * $WM_PROJECT_SITE
- //
- searchDir = getEnv("WM_PROJECT_SITE");
- if (searchDir.size())
- {
- if (isDir(searchDir))
- {
- fileName fullName = searchDir/FOAMversion/name;
- if (isFile(fullName))
- {
- results.append(fullName);
- if (findFirst)
- {
- return results;
- }
- }
-
- fullName = searchDir/name;
- if (isFile(fullName))
- {
- results.append(fullName);
- if (findFirst)
- {
- return results;
- }
- }
- }
- }
- else
- {
- // OR search for group (site) files in
- // * $WM_PROJECT_INST_DIR/site/VERSION
- // * $WM_PROJECT_INST_DIR/site
- //
- searchDir = getEnv("WM_PROJECT_INST_DIR");
- if (isDir(searchDir))
- {
- fileName fullName = searchDir/"site"/FOAMversion/name;
- if (isFile(fullName))
- {
- results.append(fullName);
- if (findFirst)
- {
- return results;
- }
- }
-
- fullName = searchDir/"site"/name;
- if (isFile(fullName))
- {
- results.append(fullName);
- if (findFirst)
- {
- return results;
- }
- }
- }
- }
-
- // Search for other (shipped) files in
- // * $WM_PROJECT_DIR/etc
- //
- searchDir = getEnv("WM_PROJECT_DIR");
- if (isDir(searchDir))
- {
- fileName fullName = searchDir/"etc"/name;
- if (isFile(fullName))
- {
- results.append(fullName);
- if (findFirst)
- {
- return results;
- }
- }
- }
-
- // Not found
- if (results.empty())
- {
- // Abort if the file is mandatory, otherwise return null
- if (mandatory)
- {
- std::cerr
- << "--> FOAM FATAL ERROR in Foam::findEtcFiles() :"
- " could not find mandatory file\n '"
- << name.c_str() << "'\n\n" << std::endl;
- ::exit(1);
- }
- }
-
- // Return list of matching paths or empty list if none found
- return results;
-}
-
-
-Foam::fileName Foam::findEtcFile(const fileName& name, bool mandatory)
-{
- fileNameList results(findEtcFiles(name, mandatory, true));
-
- if (results.size())
- {
- return results[0];
- }
- else
- {
- return fileName();
- }
-}
-
-
bool Foam::mkDir(const fileName& pathName, mode_t mode)
{
// empty names are meaningless
diff --git a/src/OSspecific/POSIX/signals/sigStopAtWriteNow.C b/src/OSspecific/POSIX/signals/sigStopAtWriteNow.C
index 3696eca38..61a968be1 100644
--- a/src/OSspecific/POSIX/signals/sigStopAtWriteNow.C
+++ b/src/OSspecific/POSIX/signals/sigStopAtWriteNow.C
@@ -145,8 +145,7 @@ void Foam::sigStopAtWriteNow::set(const bool verbose)
FatalErrorInFunction
<< "stopAtWriteNowSignal : " << signal_
<< " cannot be the same as the writeNowSignal."
- << " Please change this in the controlDict ("
- << findEtcFile("controlDict", false) << ")."
+ << " Please change this in the etc/controlDict."
<< exit(FatalError);
}
diff --git a/src/OpenFOAM/global/etcFiles/etcFiles.C b/src/OpenFOAM/global/etcFiles/etcFiles.C
new file mode 100644
index 000000000..f93f3c6ef
--- /dev/null
+++ b/src/OpenFOAM/global/etcFiles/etcFiles.C
@@ -0,0 +1,267 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
+ \\/ M anipulation |
+-------------------------------------------------------------------------------
+License
+ This file is part of OpenFOAM.
+
+ OpenFOAM is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with OpenFOAM. If not, see .
+
+\*---------------------------------------------------------------------------*/
+
+#include "etcFiles.H"
+#include "OSspecific.H"
+#include "foamVersion.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+Foam::fileNameList Foam::findEtcDirs(const fileName& local)
+{
+ fileNameList dirs;
+
+ // Search for user directories in
+ // * ~/.OpenFOAM/VERSION
+ // * ~/.OpenFOAM
+ //
+ fileName searchDir = home()/".OpenFOAM";
+ if (isDir(searchDir))
+ {
+ fileName fullName = searchDir/FOAMversion/local;
+ if (isDir(fullName))
+ {
+ dirs.append(fullName);
+ }
+
+ fullName = searchDir/local;
+ if (isDir(fullName))
+ {
+ dirs.append(fullName);
+ }
+ }
+
+ // Search for group (site) directories in
+ // * $WM_PROJECT_SITE/VERSION
+ // * $WM_PROJECT_SITE
+ //
+ searchDir = getEnv("WM_PROJECT_SITE");
+ if (searchDir.size())
+ {
+ if (isDir(searchDir))
+ {
+ fileName fullName = searchDir/FOAMversion/local;
+ if (isDir(fullName))
+ {
+ dirs.append(fullName);
+ }
+
+ fullName = searchDir/local;
+ if (isDir(fullName))
+ {
+ dirs.append(fullName);
+ }
+ }
+ }
+ else
+ {
+ // Or search for group (site) files in
+ // * $WM_PROJECT_INST_DIR/site/VERSION
+ // * $WM_PROJECT_INST_DIR/site
+ //
+ searchDir = getEnv("WM_PROJECT_INST_DIR");
+ if (isDir(searchDir))
+ {
+ fileName fullName = searchDir/"site"/FOAMversion/local;
+ if (isDir(fullName))
+ {
+ dirs.append(fullName);
+ }
+
+ fullName = searchDir/"site"/local;
+ if (isDir(fullName))
+ {
+ dirs.append(fullName);
+ }
+ }
+ }
+
+ // Search for other (shipped) files in
+ // * $WM_PROJECT_DIR/etc
+ //
+ searchDir = getEnv("WM_PROJECT_DIR");
+ if (isDir(searchDir))
+ {
+ fileName fullName = searchDir/"etc"/local;
+ if (isDir(fullName))
+ {
+ dirs.append(fullName);
+ }
+ }
+
+ return dirs;
+}
+
+
+Foam::fileNameList Foam::findEtcFiles
+(
+ const fileName& name,
+ bool mandatory,
+ bool findFirst
+)
+{
+ fileNameList results;
+
+ // Search for user files in
+ // * ~/.OpenFOAM/VERSION
+ // * ~/.OpenFOAM
+ //
+ fileName searchDir = home()/".OpenFOAM";
+ if (isDir(searchDir))
+ {
+ fileName fullName = searchDir/FOAMversion/name;
+ if (isFile(fullName))
+ {
+ results.append(fullName);
+ if (findFirst)
+ {
+ return results;
+ }
+ }
+
+ fullName = searchDir/name;
+ if (isFile(fullName))
+ {
+ results.append(fullName);
+ if (findFirst)
+ {
+ return results;
+ }
+ }
+ }
+
+ // Search for group (site) files in
+ // * $WM_PROJECT_SITE/VERSION
+ // * $WM_PROJECT_SITE
+ //
+ searchDir = getEnv("WM_PROJECT_SITE");
+ if (searchDir.size())
+ {
+ if (isDir(searchDir))
+ {
+ fileName fullName = searchDir/FOAMversion/name;
+ if (isFile(fullName))
+ {
+ results.append(fullName);
+ if (findFirst)
+ {
+ return results;
+ }
+ }
+
+ fullName = searchDir/name;
+ if (isFile(fullName))
+ {
+ results.append(fullName);
+ if (findFirst)
+ {
+ return results;
+ }
+ }
+ }
+ }
+ else
+ {
+ // Or search for group (site) files in
+ // * $WM_PROJECT_INST_DIR/site/VERSION
+ // * $WM_PROJECT_INST_DIR/site
+ //
+ searchDir = getEnv("WM_PROJECT_INST_DIR");
+ if (isDir(searchDir))
+ {
+ fileName fullName = searchDir/"site"/FOAMversion/name;
+ if (isFile(fullName))
+ {
+ results.append(fullName);
+ if (findFirst)
+ {
+ return results;
+ }
+ }
+
+ fullName = searchDir/"site"/name;
+ if (isFile(fullName))
+ {
+ results.append(fullName);
+ if (findFirst)
+ {
+ return results;
+ }
+ }
+ }
+ }
+
+ // Search for other (shipped) files in
+ // * $WM_PROJECT_DIR/etc
+ //
+ searchDir = getEnv("WM_PROJECT_DIR");
+ if (isDir(searchDir))
+ {
+ fileName fullName = searchDir/"etc"/name;
+ if (isFile(fullName))
+ {
+ results.append(fullName);
+ if (findFirst)
+ {
+ return results;
+ }
+ }
+ }
+
+ // Not found
+ if (results.empty())
+ {
+ // Abort if the file is mandatory, otherwise return null
+ if (mandatory)
+ {
+ std::cerr
+ << "--> FOAM FATAL ERROR in Foam::findEtcFiles() :"
+ " could not find mandatory file\n '"
+ << name.c_str() << "'\n\n" << std::endl;
+ ::exit(1);
+ }
+ }
+
+ // Return list of matching paths or empty list if none found
+ return results;
+}
+
+
+Foam::fileName Foam::findEtcFile(const fileName& name, bool mandatory)
+{
+ fileNameList results(findEtcFiles(name, mandatory, true));
+
+ if (results.size())
+ {
+ return results[0];
+ }
+ else
+ {
+ return fileName();
+ }
+}
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/global/etcFiles/etcFiles.H b/src/OpenFOAM/global/etcFiles/etcFiles.H
new file mode 100644
index 000000000..5b064d490
--- /dev/null
+++ b/src/OpenFOAM/global/etcFiles/etcFiles.H
@@ -0,0 +1,107 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
+ \\/ M anipulation |
+-------------------------------------------------------------------------------
+License
+ This file is part of OpenFOAM.
+
+ OpenFOAM is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with OpenFOAM. If not, see .
+
+InNamespace
+ Foam
+
+Description
+ Functions to search 'etc' directories for configuration files etc.
+
+SourceFiles
+ etcFiles.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef etcFiles_H
+#define etcFiles_H
+
+#include "fileNameList.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+//- Search for directories from user/group/shipped directories.
+// The search scheme allows for version-specific and
+// version-independent files using the following hierarchy:
+// - \b user settings:
+// - ~/.OpenFOAM/\
+// - ~/.OpenFOAM/
+// - \b group (site) settings (when $WM_PROJECT_SITE is set):
+// - $WM_PROJECT_SITE/\
+// - $WM_PROJECT_SITE
+// - \b group (site) settings (when $WM_PROJECT_SITE is not set):
+// - $WM_PROJECT_INST_DIR/site/\
+// - $WM_PROJECT_INST_DIR/site/
+// - \b other (shipped) settings:
+// - $WM_PROJECT_DIR/etc/
+//
+// \return The list of full paths of all the matching directories or
+// an empty list if the name cannot be found.
+fileNameList findEtcDirs(const fileName& local = fileName::null);
+
+//- Search for files from user/group/shipped directories.
+// The search scheme allows for version-specific and
+// version-independent files using the following hierarchy:
+// - \b user settings:
+// - ~/.OpenFOAM/\
+// - ~/.OpenFOAM/
+// - \b group (site) settings (when $WM_PROJECT_SITE is set):
+// - $WM_PROJECT_SITE/\
+// - $WM_PROJECT_SITE
+// - \b group (site) settings (when $WM_PROJECT_SITE is not set):
+// - $WM_PROJECT_INST_DIR/site/\
+// - $WM_PROJECT_INST_DIR/site/
+// - \b other (shipped) settings:
+// - $WM_PROJECT_DIR/etc/
+//
+// \return The list of full paths of all the matching files or
+// an empty list if the name cannot be found.
+// Optionally abort if the file cannot be found.
+// Optionally stop search after the first file has been found.
+fileNameList findEtcFiles
+(
+ const fileName&,
+ bool mandatory=false,
+ bool findFirst=false
+);
+
+//- Search for a file using findEtcFiles.
+// \return The full path name of the first file found in the
+// search hierarchy or an empty fileName if the name cannot be found.
+// Optionally abort if the file cannot be found.
+fileName findEtcFile(const fileName&, bool mandatory=false);
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/include/OSspecific.H b/src/OpenFOAM/include/OSspecific.H
index d190f6704..dc59042f2 100644
--- a/src/OpenFOAM/include/OSspecific.H
+++ b/src/OpenFOAM/include/OSspecific.H
@@ -92,38 +92,6 @@ fileName cwd();
// else return false
bool chDir(const fileName& dir);
-//- Search for files from user/group/shipped directories.
-// The search scheme allows for version-specific and
-// version-independent files using the following hierarchy:
-// - \b user settings:
-// - ~/.OpenFOAM/\
-// - ~/.OpenFOAM/
-// - \b group (site) settings (when $WM_PROJECT_SITE is set):
-// - $WM_PROJECT_SITE/\
-// - $WM_PROJECT_SITE
-// - \b group (site) settings (when $WM_PROJECT_SITE is not set):
-// - $WM_PROJECT_INST_DIR/site/\
-// - $WM_PROJECT_INST_DIR/site/
-// - \b other (shipped) settings:
-// - $WM_PROJECT_DIR/etc/
-//
-// \return The list of full paths of all the matching files or
-// an empty list if the name cannot be found.
-// Optionally abort if the file cannot be found.
-// Optionally stop search after the first file has been found.
-fileNameList findEtcFiles
-(
- const fileName&,
- bool mandatory=false,
- bool findFirst=false
-);
-
-//- Search for a file using findEtcFiles.
-// \return The full path name of the first file found in the
-// search hierarchy or an empty fileName if the name cannot be found.
-// Optionally abort if the file cannot be found.
-fileName findEtcFile(const fileName&, bool mandatory=false);
-
//- Make a directory and return an error if it could not be created
// and does not already exist
bool mkDir(const fileName&, mode_t=0777);