Changeset - b9a82317961f
[Not reviewed]
0 3 0
Jan Kaluza - 13 years ago 2013-01-17 09:44:57
hanzz.k@gmail.com
another try to fix createDirectories compilation for oneiric
3 files changed with 29 insertions and 3 deletions:
0 comments (0 inline, 0 general)
include/transport/util.h
Show inline comments
 
@@ -30,13 +30,13 @@
 
#include "transport/config.h"
 

	
 
namespace Transport {
 

	
 
namespace Util {
 

	
 
void createDirectories(Transport::Config *config, boost::filesystem::path ph);
 
void createDirectories(Transport::Config *config, const boost::filesystem::path& ph);
 

	
 
void removeEverythingOlderThan(const std::vector<std::string> &dirs, time_t t);
 

	
 
int getRandomPort(const std::string &s);
 

	
 
#ifdef _WIN32
spectrum/src/main.cpp
Show inline comments
 
@@ -128,12 +128,38 @@ static void daemonize(const char *cwd, const char *lock_file) {
 
		std::cout << "EE cannot open /dev/null. Exiting\n";
 
		exit(1);
 
	}
 
}
 
#endif
 

	
 
static void _createDirectories(Transport::Config *config, boost::filesystem::path ph) {
 
	if (ph.empty() || exists(ph)) {
 
		return;
 
	}
 

	
 
	// First create branch, by calling ourself recursively
 
	_createDirectories(config, ph.branch_path());
 
	
 
	// Now that parent's path exists, create the directory
 
	boost::filesystem::create_directory(ph);
 

	
 
#ifndef WIN32
 
	if (!CONFIG_STRING(config, "service.group").empty() && !CONFIG_STRING(config, "service.user").empty()) {
 
		struct group *gr;
 
		if ((gr = getgrnam(CONFIG_STRING(config, "service.group").c_str())) == NULL) {
 
			std::cerr << "Invalid service.group name " << CONFIG_STRING(config, "service.group") << "\n";
 
		}
 
		struct passwd *pw;
 
		if ((pw = getpwnam(CONFIG_STRING(config, "service.user").c_str())) == NULL) {
 
			std::cerr << "Invalid service.user name " << CONFIG_STRING(config, "service.user") << "\n";
 
		}
 
		chown(ph.string().c_str(), pw->pw_uid, gr->gr_gid);
 
	}
 
#endif
 
}
 

	
 
int mainloop() {
 

	
 
#ifndef WIN32
 
	mode_t old_cmask = umask(0007);
 
#endif
 

	
 
@@ -397,13 +423,13 @@ int main(int argc, char **argv)
 
		std::cerr << "Can't load configuration file.\n";
 
		return 1;
 
	}
 

	
 
	// create directories
 
	try {
 
		Transport::Util::createDirectories(&config, boost::filesystem::path(CONFIG_STRING(&config, "service.working_dir")));
 
		_createDirectories(&config, boost::filesystem::path(CONFIG_STRING(&config, "service.working_dir")));
 
	}
 
	catch (...) {
 
		std::cerr << "Can't create service.working_dir directory " << CONFIG_STRING(&config, "service.working_dir") << ".\n";
 
		return 1;
 
	}
 
#ifndef WIN32
src/util.cpp
Show inline comments
 
@@ -46,13 +46,13 @@ using namespace boost::filesystem;
 
using namespace boost;
 

	
 
namespace Transport {
 

	
 
namespace Util {
 

	
 
void createDirectories(Transport::Config *config, path ph) {
 
void createDirectories(Transport::Config *config, const boost::filesystem::path& ph) {
 
	if (ph.empty() || exists(ph)) {
 
		return;
 
	}
 

	
 
	// First create branch, by calling ourself recursively
 
	createDirectories(config, ph.branch_path());
0 comments (0 inline, 0 general)