mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: consistent handling of fileName concatenation (POSIX)
This commit is contained in:
@ -99,16 +99,24 @@ static inline Foam::fileName fileNameConcat
|
||||
if (b.size())
|
||||
{
|
||||
// Two non-empty strings: can concatenate
|
||||
return Foam::fileName((a + '/' + b), false);
|
||||
|
||||
if (a.back() == '/' || b.front() == '/')
|
||||
{
|
||||
return Foam::fileName(a + b, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Foam::fileName(a + '/' + b, false);
|
||||
}
|
||||
}
|
||||
|
||||
// The second string was empty
|
||||
return Foam::fileName(a, false);
|
||||
}
|
||||
|
||||
// Or, if the first string is empty
|
||||
|
||||
if (b.size())
|
||||
{
|
||||
// The first string is empty
|
||||
return Foam::fileName(b, false);
|
||||
}
|
||||
|
||||
@ -1586,21 +1594,22 @@ int Foam::system(const Foam::UList<Foam::string>& command, const bool bg)
|
||||
}
|
||||
|
||||
|
||||
void* Foam::dlOpen(const fileName& lib, const bool check)
|
||||
void* Foam::dlOpen(const fileName& libName, const bool check)
|
||||
{
|
||||
if (POSIX::debug)
|
||||
{
|
||||
std::cout<< "dlOpen(const fileName&)"
|
||||
<< " : dlopen of " << lib << std::endl;
|
||||
std::cout
|
||||
<< "dlOpen(const fileName&)"
|
||||
<< " : dlopen of " << libName << std::endl;
|
||||
}
|
||||
void* handle = ::dlopen(lib.c_str(), RTLD_LAZY|RTLD_GLOBAL);
|
||||
void* handle = ::dlopen(libName.c_str(), RTLD_LAZY|RTLD_GLOBAL);
|
||||
|
||||
#ifdef darwin
|
||||
// Re-try "libXX.so" as "libXX.dylib"
|
||||
if (!handle && lib.hasExt("so"))
|
||||
if (!handle && libName.hasExt("so"))
|
||||
{
|
||||
const fileName dylib(lib.lessExt().ext("dylib"));
|
||||
handle = ::dlopen(dylib.c_str(), RTLD_LAZY|RTLD_GLOBAL);
|
||||
const fileName dylibName(libName.lessExt().ext("dylib"));
|
||||
handle = ::dlopen(dylibName.c_str(), RTLD_LAZY|RTLD_GLOBAL);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1615,7 +1624,7 @@ void* Foam::dlOpen(const fileName& lib, const bool check)
|
||||
{
|
||||
std::cout
|
||||
<< "dlOpen(const fileName&)"
|
||||
<< " : dlopen of " << lib
|
||||
<< " : dlopen of " << libName
|
||||
<< " handle " << handle << std::endl;
|
||||
}
|
||||
|
||||
|
||||
@ -48,7 +48,7 @@ namespace Foam
|
||||
|
||||
namespace POSIX
|
||||
{
|
||||
//- Declare name of the class and its debug switch
|
||||
//- Declare namespace and its debug switch
|
||||
NamespaceName("POSIX");
|
||||
|
||||
const label pathLengthChunk = 256;
|
||||
|
||||
@ -495,7 +495,8 @@ Foam::fileName Foam::operator/(const string& a, const string& b)
|
||||
}
|
||||
}
|
||||
|
||||
return a; // The second string was empty
|
||||
// The second string was empty
|
||||
return a;
|
||||
}
|
||||
|
||||
if (b.size())
|
||||
|
||||
Reference in New Issue
Block a user