本文整理汇总了C++中OsPath::data方法的典型用法代码示例。如果您正苦于以下问题:C++ OsPath::data方法的具体用法?C++ OsPath::data怎么用?C++ OsPath::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OsPath
的用法示例。
在下文中一共展示了OsPath::data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setLogPriority
void SipXecsService::setLogPriority(const char* configSettingsFile, // path to configuration file
const char* servicePrefix, /* the string "_LOG_LEVEL" is
* appended to this prefix to find
* the config directive that sets
* the level */
OsSysLogPriority defaultLevel /* used if no directive
* is found, or the value
* found is not a valid
* level name */
)
{
OsConfigDb configuration;
OsPath configPath = SipXecsService::Path(SipXecsService::ConfigurationDirType,
configSettingsFile);
if (OS_SUCCESS == configuration.loadFromFile(configPath.data()))
{
setLogPriority(configuration, servicePrefix, defaultLevel);
}
else
{
OsSysLog::add(FAC_KERNEL, PRI_WARNING,
"SipXecsService::setLogPriority: Failed to open config file at '%s'\n"
" setting %s%s to %s",
configPath.data(),
servicePrefix, LogLevelSuffix, OsSysLog::priorityName(defaultLevel)
);
OsSysLog::setLoggingPriority(defaultLevel);
}
}
示例2: remove
//: Removes the directory or file specified by path
OsStatus OsFileSystem::remove(const OsPath& path, UtlBoolean bRecursive, UtlBoolean bForce)
{
OsStatus retval = OS_INVALID;
OsFileInfo info;
OsPath testpath = path;
getFileInfo(testpath,info);
if (info.isDir())
{
if (bRecursive)
{
retval = removeTree(path,bForce);
}
else
{
if (rmdir((char *)path.data()) != -1)
retval = OS_SUCCESS;
}
}
else
{
if (bForce)
setReadOnly(path,FALSE);
if (::remove(path.data()) != -1)
retval = OS_SUCCESS;
}
return retval;
}
示例3: loadAllDynCodecs
OsStatus MpCodecFactory::loadAllDynCodecs(const char* path, const char* regexFilter)
{
OsPath ospath = path;
OsPath module;
OsFileIterator fi(ospath);
OsSysLog::add(FAC_MP, PRI_INFO, "MpCodecFactory::loadAllDynCodecs(\"%s\", \"%s\")",
path, regexFilter);
OsStatus res;
res = fi.findFirst(module, regexFilter);
if (res != OS_SUCCESS)
return OS_NOT_FOUND;
do {
UtlString str = path;
str += OsPathBase::separator;
str += module.data();
res = loadDynCodec(str.data());
OsSysLog::add(FAC_MP, PRI_INFO, "MpCodecFactory::loadDynCodec(\"%s\") returned %d",
str.data(), res);
} while (fi.findNext(module) == OS_SUCCESS);
return OS_SUCCESS;
}
示例4: instantiateProcesses
/// Find process definitions and instantiate SipxProcess objects for each.
void SipxProcessManager::instantiateProcesses(const OsPath& processDefinitionDirectory)
{
OsFileIterator definitions(processDefinitionDirectory);
OsPath processDefinitionFile;
OsStatus iteratorStatus;
Os::Logger::instance().log(FAC_SUPERVISOR, PRI_DEBUG,"SipxProcessManager::instantiateProcesses searching %s",
processDefinitionDirectory.data()
);
for ( iteratorStatus = definitions.findFirst(processDefinitionFile,
PROCESS_DEFINITION_NAME_PATTERN,
OsFileIterator::FILES);
OS_SUCCESS == iteratorStatus;
iteratorStatus = definitions.findNext(processDefinitionFile)
)
{
OsPath processDefinitionPath( processDefinitionDirectory
+OsPath::separator
+processDefinitionFile
);
Os::Logger::instance().log(FAC_SUPERVISOR, PRI_DEBUG,"SipxProcessManager::instantiateProcesses reading %s",
processDefinitionPath.data()
);
SipxProcess::createFromDefinition(processDefinitionPath);
}
}
示例5: change
//: Change the current working directory to the specified location
OsStatus OsFileSystem::change(const OsPath& path)
{
OsStatus stat = OS_INVALID;
OsPath dir = path;
if (chdir((char*) path.data()) != -1)
stat = OS_SUCCESS;
return stat;
}
示例6: Path
OsPath SipXecsService::Path(DirectoryType pathType, const char* fileName)
{
OsPath path;
const char* dirPath;
if ( (dirPath = getenv(pathType)) )
{
OsSysLog::add(FAC_KERNEL, PRI_NOTICE,
"SipXecsService::Path type '%s' overridden by environment to '%s'",
pathType, dirPath);
}
else
{
dirPath = defaultDir(pathType);
}
path.append(dirPath);
const char slash = OsPath::separator(0);
const char lastPathChar = path(path.length()-1);
if (fileName && *fileName != '\000')
{
// Add the file name
// make sure there is exactly one separator between the directory and the file
if ( slash != lastPathChar
&& slash != fileName[0]
)
{
// neither has separator - add one
path.append(OsPath::separator);
}
else if ( slash == lastPathChar
&& slash == fileName[0]
)
{
// both have the separator - take one off so there's only one
path.remove(path.length()-1);
}
path.append(fileName);
}
// There is no file name, so make sure the returned directory name does not
// end in a separator
else if ( slash == lastPathChar )
{
path.remove(path.length()-1);
}
OsSysLog::add(FAC_KERNEL, PRI_DEBUG,
"SipXecsService::Path('%s', '%s') returning '%s'",
pathType, fileName ? fileName : "", path.data() );
return path;
}
示例7: createDummyFile
OsStatus OsTestUtilities::createDummyFile(OsPath testFile, unsigned long size)
{
printf("OsTestUtilities::createDummyFile(%s, %ld)\n", testFile.data(), size);
OsStatus stat;
char wbuff[10000];
unsigned long wbuffsize = (unsigned long)sizeof(wbuff);
OsTestUtilities::initDummyBuffer(wbuff, sizeof(wbuff));
printf("construct OsFile\n");
OsFile wfile(testFile);
printf("opening %s\n", testFile.data());
stat = wfile.open(OsFile::CREATE);
printf("created\n");
UtlString msg("failed to create file: ");
msg.append(testFile);
msg.appendFormat(" error: %d", stat);
CPPUNIT_ASSERT_MESSAGE(msg.data(), stat == OS_SUCCESS);
if (stat == OS_SUCCESS)
{
printf("stat ok\n");
unsigned long wposition = 0;
for (int i = 0; stat == OS_SUCCESS && wposition < wbuffsize; i++)
{
printf("about to write\n");
unsigned long remaining = wbuffsize - wposition;
unsigned long byteswritten = 0;
stat = wfile.write(wbuff + wposition, remaining, byteswritten);
printf("write %ld bytes return: %d\n", (long)byteswritten, (int)stat);
wposition += byteswritten;
}
wfile.close();
}
printf("exit OsTestUtilities::createDummyFile\n");
return stat;
}
示例8: recordMatch
/**
* Find the element in TestFiles that was matched, and record that
* fact in the results array.
* We do it this way because the order in which the matches will
* occur is undefined.
*/
void recordMatch( bool results[NumTestFiles], OsPath& matched )
{
int file;
bool found;
TRACE_TEST(("\n ####### found '%s'", matched.data()));
for ( file = 0, found = false; file < NumTestFiles && ! found; file++ )
{
if ( matched == TestFiles[file] )
{
CPPUNIT_ASSERT_MESSAGE( "Found the same file twice.", results );
results[file] = true;
found = true;
}
}
CPPUNIT_ASSERT_MESSAGE( "Found a file not in the test set.", found );
}
示例9: setReadOnly
OsStatus OsFileSystem::setReadOnly(const OsPath& rPath, UtlBoolean isReadOnly)
{
OsStatus retval = OS_FAILED;
#ifdef _VXWORKS
#else
int mode = S_IREAD;
if (!isReadOnly)
mode |= S_IWRITE;
if (chmod(rPath.data(),mode) != -1)
retval = OS_SUCCESS;
#endif
return retval;
}
示例10: createTestDir
void OsTestUtilities::createTestDir(OsPath& root)
{
OsStatus stat;
#ifdef ANDROID
root = "/sdcard";
#else
OsFileSystem::getWorkingDirectory(root);
#endif
printf("Test dir root: %s\n", root.data());
root.append(OsPath::separator).append("OsFileSystemTest");
if (OsFileSystem::exists(root))
{
removeTestDir(root);
}
stat = OsFileSystem::createDir(root);
CPPUNIT_ASSERT_MESSAGE("setup root test dir", stat == OS_SUCCESS);
}
示例11: verifyDummyFile
UtlBoolean OsTestUtilities::verifyDummyFile(OsPath testFile, unsigned long size)
{
OsStatus stat;
UtlBoolean ok = false;
char rbuff[256];
unsigned long rbuffsize = (unsigned long)sizeof(rbuff);
OsFile rfile(testFile);
stat = rfile.open();
UtlString msg("Failed to create file: ");
msg.append(testFile);
CPPUNIT_ASSERT_MESSAGE(testFile.data(), stat == OS_SUCCESS);
if (stat == OS_SUCCESS)
{
unsigned long rposition = 0;
ok = true;
for (int i = 0; ok && rposition < size; i++)
{
unsigned long remaining = (size - rposition);
unsigned long readsize = remaining < rbuffsize ? remaining : rbuffsize;
unsigned long bytesread = 0;
stat = rfile.read(rbuff, readsize, bytesread);
CPPUNIT_ASSERT_MESSAGE("Failed to read", stat != 0);
if (stat != OS_SUCCESS)
{
ok = false;
printf("Error reading file, status = %i", stat);
}
else
{
ok = OsTestUtilities::testDummyBuffer(rbuff, bytesread, rposition);
rposition += bytesread;
}
}
rfile.close();
}
return ok;
}
示例12: initSysLog
/**
* Description:
* closes any open connections to the IMDB safely using a mutex lock
*/
void initSysLog(OsConfigDb* pConfig)
{
UtlString consoleLogging; // Enable console logging by default?
UtlString fileTarget; // Path to store log file.
UtlBoolean bSpecifiedDirError ; // Set if the specified log dir does not
// exist
Os::LoggerHelper::instance().processName = "SipXProxy";
//
// Get/Apply Log Filename
//
if ((pConfig->get(CONFIG_SETTING_LOG_DIR, fileTarget) != OS_SUCCESS) ||
fileTarget.isNull() || !OsFileSystem::exists(fileTarget))
{
bSpecifiedDirError = !fileTarget.isNull() ;
// If the log file directory exists use that, otherwise place the log
// in the current directory
OsPath workingDirectory;
if (OsFileSystem::exists(CONFIG_LOG_DIR))
{
fileTarget = CONFIG_LOG_DIR;
OsPath path(fileTarget);
path.getNativePath(workingDirectory);
osPrintf("%s : %s\n", CONFIG_SETTING_LOG_DIR, workingDirectory.data()) ;
Os::Logger::instance().log(FAC_SIP, PRI_INFO, "%s : %s", CONFIG_SETTING_LOG_DIR, workingDirectory.data()) ;
}
else
{
OsPath path;
OsFileSystem::getWorkingDirectory(path);
path.getNativePath(workingDirectory);
osPrintf("%s : %s\n", CONFIG_SETTING_LOG_DIR, workingDirectory.data()) ;
Os::Logger::instance().log(FAC_SIP, PRI_INFO, "%s : %s", CONFIG_SETTING_LOG_DIR, workingDirectory.data()) ;
}
fileTarget = workingDirectory + OsPathBase::separator + SIPX_PROXY_LOG_FILE;
}
else
{
bSpecifiedDirError = false ;
osPrintf("%s : %s\n", CONFIG_SETTING_LOG_DIR, fileTarget.data()) ;
Os::Logger::instance().log(FAC_SIP, PRI_INFO, "%s : %s", CONFIG_SETTING_LOG_DIR, fileTarget.data()) ;
fileTarget = fileTarget +
OsPathBase::separator +
SIPX_PROXY_LOG_FILE;
}
//
// Get/Apply Log Level
//
SipXecsService::setLogPriority( CONFIG_SETTINGS_FILE, PROXY_CONFIG_PREFIX );
Os::Logger::instance().setLoggingPriorityForFacility(FAC_SIP_INCOMING_PARSED, PRI_ERR);
Os::LoggerHelper::instance().initialize(fileTarget.data());
//
// Get/Apply console logging
//
UtlBoolean bConsoleLoggingEnabled = false ;
if ((pConfig->get(CONFIG_SETTING_LOG_CONSOLE, consoleLogging) ==
OS_SUCCESS))
{
consoleLogging.toUpper();
if (consoleLogging == "ENABLE")
{
Os::Logger::instance().enableConsoleOutput(true);
bConsoleLoggingEnabled = true ;
}
}
osPrintf("%s : %s\n", CONFIG_SETTING_LOG_CONSOLE, bConsoleLoggingEnabled ? "ENABLE" : "DISABLE") ;
Os::Logger::instance().log(FAC_SIP, PRI_INFO, "%s : %s",
CONFIG_SETTING_LOG_CONSOLE, bConsoleLoggingEnabled ? "ENABLE" : "DISABLE") ;
if (bSpecifiedDirError)
{
Os::Logger::instance().log(FAC_LOG, PRI_CRIT,
"Cannot access %s directory; please check configuration.",
CONFIG_SETTING_LOG_DIR);
}
}
示例13: proxy
int proxy()
{
int proxyTcpPort;
int proxyUdpPort;
int proxyTlsPort;
UtlString bindIp;
int maxForwards;
UtlString domainName;
UtlString proxyRecordRoute;
UtlString routeName;
UtlString authScheme;
UtlString ipAddress;
OsMsgQShared::setQueuePreference(OsMsgQShared::QUEUE_UNLIMITED);
OsSocket::getHostIp(&ipAddress);
OsPath ConfigfileName = SipXecsService::Path(SipXecsService::ConfigurationDirType,
CONFIG_SETTINGS_FILE);
OsConfigDb configDb;
if(OS_SUCCESS != configDb.loadFromFile(ConfigfileName))
{
exit(1);
}
// Initialize the OsSysLog...
initSysLog(&configDb);
std::set_terminate(catch_global);
configDb.get(CONFIG_SETTING_BIND_IP, bindIp);
if ((bindIp.isNull()) || !OsSocket::isIp4Address(bindIp))
{
bindIp = "0.0.0.0";
}
Os::Logger::instance().log(FAC_SIP, PRI_INFO, "%s: %s", CONFIG_SETTING_BIND_IP,
bindIp.data());
osPrintf("%s: %s", CONFIG_SETTING_BIND_IP, bindIp.data());
UtlString hostname;
configDb.get("SIPX_PROXY_HOST_NAME", hostname);
if (!hostname.isNull())
{
// bias the selection of SRV records so that if the name of this host is an alternative,
// it wins in any selection based on random weighting.
SipSrvLookup::setOwnHostname(hostname);
}
Os::Logger::instance().log(FAC_SIP, PRI_INFO, "SIPX_PROXY_HOST_NAME : %s", hostname.data());
proxyUdpPort = configDb.getPort("SIPX_PROXY_UDP_PORT");
if (!portIsValid(proxyUdpPort))
{
proxyUdpPort = 5060;
}
Os::Logger::instance().log(FAC_SIP, PRI_INFO, "SIPX_PROXY_UDP_PORT : %d", proxyUdpPort);
proxyTcpPort = configDb.getPort("SIPX_PROXY_TCP_PORT") ;
if (!portIsValid(proxyTcpPort))
{
proxyTcpPort = 5060;
}
Os::Logger::instance().log(FAC_SIP, PRI_INFO, "SIPX_PROXY_TCP_PORT : %d", proxyTcpPort);
proxyTlsPort = configDb.getPort("SIPX_PROXY_TLS_PORT") ;
if (!portIsValid(proxyTlsPort))
{
proxyTlsPort = 5061;
}
Os::Logger::instance().log(FAC_SIP, PRI_INFO, "SIPX_PROXY_TLS_PORT : %d", proxyTlsPort);
configDb.get("SIPX_PROXY_MAX_FORWARDS", maxForwards);
if(maxForwards <= 0) maxForwards = SIP_DEFAULT_MAX_FORWARDS;
Os::Logger::instance().log(FAC_SIP, PRI_INFO, "SIPX_PROXY_MAX_FORWARDS : %d", maxForwards);
osPrintf("SIPX_PROXY_MAX_FORWARDS : %d\n", maxForwards);
int branchTimeout = -1;
configDb.get("SIPX_PROXY_BRANCH_TIMEOUT", branchTimeout);
if(branchTimeout < 4)
{
branchTimeout = 24;
}
int defaultExpires;
int defaultSerialExpires;
configDb.get("SIPX_PROXY_DEFAULT_EXPIRES", defaultExpires);
configDb.get("SIPX_PROXY_DEFAULT_SERIAL_EXPIRES", defaultSerialExpires);
if(defaultExpires <= 0 )
{
defaultExpires = DEFAULT_SIP_TRANSACTION_EXPIRES;
}
else if(defaultExpires > DEFAULT_SIP_TRANSACTION_EXPIRES)
{
Os::Logger::instance().log(FAC_SIP, PRI_WARNING,
"SipXproxymain::proxy "
"large default expires value: %d NOT RECOMMENDED",
defaultExpires);
}
if(defaultSerialExpires <= 0 ||
defaultSerialExpires >= defaultExpires)
{
defaultSerialExpires = DEFAULT_SIP_SERIAL_EXPIRES;
}
Os::Logger::instance().log(FAC_SIP, PRI_INFO, "SIPX_PROXY_DEFAULT_EXPIRES : %d", defaultExpires);
//.........这里部分代码省略.........
示例14: removeTree
//: Removes the directory annd all sub-dirs
OsStatus OsFileSystem::removeTree(const OsPath& path,UtlBoolean bForce)
{
UtlBoolean bFailed = FALSE;
OsPath origDir;
OsFileSystem::getWorkingDirectory(origDir);
OsStatus retval = OS_INVALID;
OsFileInfo info;
OsPath testpath = path;
getFileInfo(testpath,info);
OsFileIterator::OsFileType fileType = OsFileIterator::ANY_FILE;
//only do this if it is a directory
if (info.isDir())
{
if (OsFileSystem::change(path) == OS_SUCCESS)
{
OsFileIterator *files = new OsFileIterator();
OsPath entry;
OsStatus filestat = files->findFirst(entry,".*", fileType);
while (!bFailed && filestat == OS_SUCCESS)
{
if (entry != "." && entry != "..")
{
getFileInfo(entry,info);
if (info.isDir())
{
if (removeTree(entry,bForce) != OS_SUCCESS)
{
bFailed = TRUE;
}
}
else
{
OsFile tmpfile(entry);
if (tmpfile.remove(bForce) != OS_SUCCESS)
{
osPrintf("ERROR: can't removing file %s\n",entry.data());
retval = OS_FAILED;
bFailed = TRUE;
}
}
}
filestat = files->findNext(entry);
}
delete files;
if (OsFileSystem::change(origDir) == OS_SUCCESS)
{
if (!bFailed && OsFileSystem::remove(path,FALSE,FALSE) != OS_SUCCESS)
{
osPrintf("ERROR: can't remove dir %s\n",path.data());
retval = OS_FAILED;
}
else
{
retval = OS_SUCCESS;
}
}
else
{
retval = OS_FAILED;
}
}
}
return retval;
}
示例15: supervisorMain
int supervisorMain(bool bOriginalSupervisor)
{
// Create forked process which will do nothing unless parent dies. Parent continues with initialization.
forkSupervisorInWaiting();
// Drop privileges down to the specified user & group
const char * sipxpbxuser = SipXecsService::User();
const char * sipxpbxgroup = SipXecsService::Group();
if (NULL == sipxpbxuser || 0 == strlen(sipxpbxuser))
{
osPrintf("sipXsupervisor: Failed to setuid(%s), username not defined.\n",
sipxpbxuser);
return 2;
}
if (NULL == sipxpbxgroup || 0 == strlen(sipxpbxgroup))
{
osPrintf("sipXsupervisor: Failed to setgid(%s), groupname not defined.\n",
sipxpbxgroup);
return 2;
}
struct group * grp = getgrnam(sipxpbxgroup);
if (NULL == grp)
{
if (0 != errno)
{
osPrintf("getgrnam(%s) failed, errno = %d.",
sipxpbxgroup, errno);
}
else
{
osPrintf(
"sipXsupervisor: getgrnam(%s) failed, user does not exist.",
sipxpbxgroup);
}
return 3;
}
struct passwd * pwd = getpwnam(sipxpbxuser);
if (NULL == pwd)
{
if (0 != errno)
{
osPrintf("getpwnam(%s) failed, errno = %d.",
sipxpbxuser, errno);
}
else
{
osPrintf(
"sipXsupervisor: getpwnam(%s) failed, user does not exist.",
sipxpbxuser);
}
return 3;
}
// Change group first, cause once user is changed this cannot be done.
if (0 != setgid(grp->gr_gid))
{
osPrintf("sipXsupervisor: setgid(%d) failed, errno = %d.",
(int)grp->gr_gid, errno);
return 4;
}
if (0 != setuid(pwd->pw_uid))
{
osPrintf("sipXsupervisor: setuid(%d) failed, errno = %d.",
(int)pwd->pw_uid, errno);
return 4;
}
# if 0
// Only output problems. This keeps the startup output clean.
osPrintf("sipXsupervisor: Dropped privileges with setuid(%s)/setgid(%s).",
sipxpbxuser, sipxpbxgroup);
#endif
OsMsgQShared::setQueuePreference(OsMsgQShared::QUEUE_UNLIMITED);
// Block all signals in this the main thread
// Any threads created after this will have all signals masked.
OsTask::blockSignals();
// Create a new task to wait for signals. Only that task
// will ever see a signal from the outside.
SignalTask* signalTask = new SignalTask();
signalTask->start() ;
// All osPrintf output should go to the console until the log file is initialized.
enableConsoleOutput(true);
// Initialize the log file.
Os::LoggerHelper::instance().processName = "Supervisor";
UtlString logFile = SipXecsService::Path(SipXecsService::LogDirType, "sipxsupervisor.log");
Os::LoggerHelper::instance().initialize(PRI_DEBUG, logFile.data());
if (!bOriginalSupervisor)
{
Os::Logger::instance().log(FAC_SUPERVISOR, PRI_CRIT,
//.........这里部分代码省略.........