mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: OSspecific: make userName,domainName,hostName strings
This commit is contained in:
@ -123,7 +123,7 @@ bool Foam::setEnv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::word Foam::hostName(bool full)
|
Foam::string Foam::hostName(bool full)
|
||||||
{
|
{
|
||||||
char buf[128];
|
char buf[128];
|
||||||
::gethostname(buf, sizeof(buf));
|
::gethostname(buf, sizeof(buf));
|
||||||
@ -142,7 +142,7 @@ Foam::word Foam::hostName(bool full)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::word Foam::domainName()
|
Foam::string Foam::domainName()
|
||||||
{
|
{
|
||||||
char buf[128];
|
char buf[128];
|
||||||
::gethostname(buf, sizeof(buf));
|
::gethostname(buf, sizeof(buf));
|
||||||
@ -159,11 +159,11 @@ Foam::word Foam::domainName()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return word::null;
|
return string::null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::word Foam::userName()
|
Foam::string Foam::userName()
|
||||||
{
|
{
|
||||||
struct passwd* pw = ::getpwuid(::getuid());
|
struct passwd* pw = ::getpwuid(::getuid());
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ Foam::word Foam::userName()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return word::null;
|
return string::null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,7 +209,7 @@ Foam::fileName Foam::home()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::fileName Foam::home(const word& userName)
|
Foam::fileName Foam::home(const string& userName)
|
||||||
{
|
{
|
||||||
struct passwd* pw;
|
struct passwd* pw;
|
||||||
|
|
||||||
@ -1069,7 +1069,7 @@ void Foam::fdClose(const int fd)
|
|||||||
|
|
||||||
bool Foam::ping
|
bool Foam::ping
|
||||||
(
|
(
|
||||||
const word& destName,
|
const string& destName,
|
||||||
const label destPort,
|
const label destPort,
|
||||||
const label timeOut
|
const label timeOut
|
||||||
)
|
)
|
||||||
@ -1083,7 +1083,7 @@ bool Foam::ping
|
|||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"Foam::ping(const word&, ...)"
|
"Foam::ping(const string&, ...)"
|
||||||
) << "gethostbyname error " << h_errno << " for host " << destName
|
) << "gethostbyname error " << h_errno << " for host " << destName
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
@ -1097,7 +1097,7 @@ bool Foam::ping
|
|||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"Foam::ping(const word&, const label)"
|
"Foam::ping(const string&, const label)"
|
||||||
) << "socket error"
|
) << "socket error"
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
@ -1149,7 +1149,7 @@ bool Foam::ping
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::ping(const word& hostname, const label timeOut)
|
bool Foam::ping(const string& hostname, const label timeOut)
|
||||||
{
|
{
|
||||||
return ping(hostname, 222, timeOut) || ping(hostname, 22, timeOut);
|
return ping(hostname, 222, timeOut) || ping(hostname, 22, timeOut);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -726,7 +726,7 @@ Foam::argList::argList
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wordList slaveProcs;
|
stringList slaveProcs;
|
||||||
|
|
||||||
// collect slave machine/pid
|
// collect slave machine/pid
|
||||||
if (parRunControl_.parRun())
|
if (parRunControl_.parRun())
|
||||||
@ -734,7 +734,7 @@ Foam::argList::argList
|
|||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
slaveProcs.setSize(Pstream::nProcs() - 1);
|
slaveProcs.setSize(Pstream::nProcs() - 1);
|
||||||
word slaveMachine;
|
string slaveMachine;
|
||||||
label slavePid;
|
label slavePid;
|
||||||
|
|
||||||
label procI = 0;
|
label procI = 0;
|
||||||
|
|||||||
@ -69,13 +69,13 @@ bool setEnv(const word& name, const std::string& value, const bool overwrite);
|
|||||||
|
|
||||||
//- Return the system's host name, as per hostname(1)
|
//- Return the system's host name, as per hostname(1)
|
||||||
// Optionally with the full name (as per the '-f' option)
|
// Optionally with the full name (as per the '-f' option)
|
||||||
word hostName(const bool full=false);
|
string hostName(const bool full=false);
|
||||||
|
|
||||||
//- Return the system's domain name, as per hostname(1) with the '-d' option
|
//- Return the system's domain name, as per hostname(1) with the '-d' option
|
||||||
word domainName();
|
string domainName();
|
||||||
|
|
||||||
//- Return the user's login name
|
//- Return the user's login name
|
||||||
word userName();
|
string userName();
|
||||||
|
|
||||||
//- Is user administrator
|
//- Is user administrator
|
||||||
bool isAdministrator();
|
bool isAdministrator();
|
||||||
@ -84,7 +84,7 @@ bool isAdministrator();
|
|||||||
fileName home();
|
fileName home();
|
||||||
|
|
||||||
//- Return home directory path name for a particular user
|
//- Return home directory path name for a particular user
|
||||||
fileName home(const word& userName);
|
fileName home(const string& userName);
|
||||||
|
|
||||||
//- Return current working directory path name
|
//- Return current working directory path name
|
||||||
fileName cwd();
|
fileName cwd();
|
||||||
@ -189,10 +189,10 @@ unsigned int sleep(const unsigned int);
|
|||||||
void fdClose(const int);
|
void fdClose(const int);
|
||||||
|
|
||||||
//- Check if machine is up by pinging given port
|
//- Check if machine is up by pinging given port
|
||||||
bool ping(const word&, const label port, const label timeOut);
|
bool ping(const string&, const label port, const label timeOut);
|
||||||
|
|
||||||
//- Check if machine is up by pinging port 22 (ssh) and 222 (rsh)
|
//- Check if machine is up by pinging port 22 (ssh) and 222 (rsh)
|
||||||
bool ping(const word&, const label timeOut=10);
|
bool ping(const string&, const label timeOut=10);
|
||||||
|
|
||||||
//- Execute the specified command
|
//- Execute the specified command
|
||||||
int system(const std::string& command);
|
int system(const std::string& command);
|
||||||
|
|||||||
@ -548,7 +548,7 @@ Foam::string& Foam::stringOps::inplaceExpand
|
|||||||
// ~OpenFOAM => site/user OpenFOAM configuration directory
|
// ~OpenFOAM => site/user OpenFOAM configuration directory
|
||||||
// ~user => home directory for specified user
|
// ~user => home directory for specified user
|
||||||
|
|
||||||
word user;
|
string user;
|
||||||
fileName file;
|
fileName file;
|
||||||
|
|
||||||
if ((begVar = s.find('/')) != string::npos)
|
if ((begVar = s.find('/')) != string::npos)
|
||||||
|
|||||||
Reference in New Issue
Block a user