summaryrefslogtreecommitdiff
path: root/orkbasecxx/BatchProcessing.cpp
diff options
context:
space:
mode:
authorGerald Begumisa <ben_g@users.sourceforge.net>2007-08-17 06:01:09 +0000
committerGerald Begumisa <ben_g@users.sourceforge.net>2007-08-17 06:01:09 +0000
commit23842e0a148920ed0ad624e81de8d73e00980140 (patch)
tree394ec965e54127812055ad81f7993796ad55344e /orkbasecxx/BatchProcessing.cpp
parent3c51d0a86548070aa9e36f87b8bf21ccdbd8b776 (diff)
Adjustment such that if the configuration options AudioFilePermissions, AudioFileOwner or AudioFileGroup are not set, the default values are used
git-svn-id: https://oreka.svn.sourceforge.net/svnroot/oreka/trunk@468 09dcff7a-b715-0410-9601-b79a96267cd0
Diffstat (limited to 'orkbasecxx/BatchProcessing.cpp')
-rw-r--r--orkbasecxx/BatchProcessing.cpp78
1 files changed, 42 insertions, 36 deletions
diff --git a/orkbasecxx/BatchProcessing.cpp b/orkbasecxx/BatchProcessing.cpp
index 5659122..62d4d2d 100644
--- a/orkbasecxx/BatchProcessing.cpp
+++ b/orkbasecxx/BatchProcessing.cpp
@@ -326,49 +326,62 @@ void BatchProcessing::ThreadHandler(void *args)
//LOG4CXX_INFO(LOG.batchProcessingLog, "[" + trackingId + "] Th" + threadIdString + " audioFileName: " + audioFileName + " mcfFileName: " + mcfFileName);
#ifndef WIN32
- if(chmod(audioFileName.c_str(), CONFIG.m_audioFilePermissions))
- {
- CStdString logMsg;
+ if(CONFIG.m_audioFilePermissions) {
+ if(chmod(audioFileName.c_str(), CONFIG.m_audioFilePermissions))
+ {
+ CStdString logMsg;
- logMsg.Format("Error setting permissions of %s to %o: %s", audioFileName.c_str(), CONFIG.m_audioFilePermissions, strerror(errno));
- LOG4CXX_INFO(LOG.batchProcessingLog, "[" + trackingId + "] Th" + threadIdString + " " + logMsg);
+ logMsg.Format("Error setting permissions of %s to %o: %s", audioFileName.c_str(), CONFIG.m_audioFilePermissions, strerror(errno));
+ LOG4CXX_INFO(LOG.batchProcessingLog, "[" + trackingId + "] Th" + threadIdString + " " + logMsg);
+ }
}
- if(chmod(mcfFileName.c_str(), CONFIG.m_audioFilePermissions))
- {
- CStdString logMsg;
+ if(CONFIG.m_audioFilePermissions) {
+ if(chmod(mcfFileName.c_str(), CONFIG.m_audioFilePermissions))
+ {
+ CStdString logMsg;
- logMsg.Format("Error setting permissions of %s to %o: %s", mcfFileName.c_str(), CONFIG.m_audioFilePermissions, strerror(errno));
- LOG4CXX_INFO(LOG.batchProcessingLog, "[" + trackingId + "] Th" + threadIdString + " " + logMsg);
+ logMsg.Format("Error setting permissions of %s to %o: %s", mcfFileName.c_str(), CONFIG.m_audioFilePermissions, strerror(errno));
+ LOG4CXX_INFO(LOG.batchProcessingLog, "[" + trackingId + "] Th" + threadIdString + " " + logMsg);
+ }
}
- struct group fileGroup, *fgP = NULL;
- struct passwd fileUser, *fuP = NULL;
- char infoGroupBuf[4096], infoUserBuf[4096];
+ if(CONFIG.m_audioFileGroup.size() && CONFIG.m_audioFileOwner.size()) {
+ struct group fileGroup, *fgP = NULL;
+ struct passwd fileUser, *fuP = NULL;
+ char infoGroupBuf[4096], infoUserBuf[4096];
- memset(infoGroupBuf, 0, sizeof(infoGroupBuf));
- memset(infoUserBuf, 0, sizeof(infoUserBuf));
- memset(&fileGroup, 0, sizeof(fileGroup));
- memset(&fileUser, 0, sizeof(fileUser));
+ memset(infoGroupBuf, 0, sizeof(infoGroupBuf));
+ memset(infoUserBuf, 0, sizeof(infoUserBuf));
+ memset(&fileGroup, 0, sizeof(fileGroup));
+ memset(&fileUser, 0, sizeof(fileUser));
- if(!getgrnam_r(CONFIG.m_audioFileGroup.c_str(), &fileGroup, infoGroupBuf, sizeof(infoGroupBuf), &fgP))
- {
- if(!getpwnam_r(CONFIG.m_audioFileOwner.c_str(), &fileUser, infoUserBuf, sizeof(infoUserBuf), &fuP))
+ if(!getgrnam_r(CONFIG.m_audioFileGroup.c_str(), &fileGroup, infoGroupBuf, sizeof(infoGroupBuf), &fgP))
{
-
- if(chown(audioFileName.c_str(), fileUser.pw_uid, fileGroup.gr_gid))
+ if(!getpwnam_r(CONFIG.m_audioFileOwner.c_str(), &fileUser, infoUserBuf, sizeof(infoUserBuf), &fuP))
{
- CStdString logMsg;
- logMsg.Format("Error setting ownership and group of %s to %s:%s: %s", audioFileName.c_str(), CONFIG.m_audioFileOwner, CONFIG.m_audioFileGroup, strerror(errno));
- LOG4CXX_INFO(LOG.batchProcessingLog, "[" + trackingId + "] Th" + threadIdString + " " + logMsg);
- }
+ if(chown(audioFileName.c_str(), fileUser.pw_uid, fileGroup.gr_gid))
+ {
+ CStdString logMsg;
+
+ logMsg.Format("Error setting ownership and group of %s to %s:%s: %s", audioFileName.c_str(), CONFIG.m_audioFileOwner, CONFIG.m_audioFileGroup, strerror(errno));
+ LOG4CXX_INFO(LOG.batchProcessingLog, "[" + trackingId + "] Th" + threadIdString + " " + logMsg);
+ }
+
+ if(chown(mcfFileName.c_str(), fileUser.pw_uid, fileGroup.gr_gid))
+ {
+ CStdString logMsg;
- if(chown(mcfFileName.c_str(), fileUser.pw_uid, fileGroup.gr_gid))
+ logMsg.Format("Error setting ownership and group of %s to %s:%s: %s", mcfFileName.c_str(), CONFIG.m_audioFileOwner, CONFIG.m_audioFileGroup, strerror(errno));
+ LOG4CXX_INFO(LOG.batchProcessingLog, "[" + trackingId + "] Th" + threadIdString + " " + logMsg);
+ }
+ }
+ else
{
CStdString logMsg;
- logMsg.Format("Error setting ownership and group of %s to %s:%s: %s", mcfFileName.c_str(), CONFIG.m_audioFileOwner, CONFIG.m_audioFileGroup, strerror(errno));
+ logMsg.Format("Failed to get user information for user %s, please check the AudioFileOwner parameter in config.xml", CONFIG.m_audioFileOwner);
LOG4CXX_INFO(LOG.batchProcessingLog, "[" + trackingId + "] Th" + threadIdString + " " + logMsg);
}
}
@@ -376,17 +389,10 @@ void BatchProcessing::ThreadHandler(void *args)
{
CStdString logMsg;
- logMsg.Format("Failed to get user information for user %s, please check the AudioFileOwner parameter in config.xml", CONFIG.m_audioFileOwner);
+ logMsg.Format("Failed to get group information for group %s, please check the AudioFileGroup parameter in config.xml", CONFIG.m_audioFileGroup);
LOG4CXX_INFO(LOG.batchProcessingLog, "[" + trackingId + "] Th" + threadIdString + " " + logMsg);
}
}
- else
- {
- CStdString logMsg;
-
- logMsg.Format("Failed to get group information for group %s, please check the AudioFileGroup parameter in config.xml", CONFIG.m_audioFileGroup);
- LOG4CXX_INFO(LOG.batchProcessingLog, "[" + trackingId + "] Th" + threadIdString + " " + logMsg);
- }
#endif
if(CONFIG.m_deleteNativeFile)