Changeset - b9a82317961f
[Not reviewed]
0 3 0
Jan Kaluza - 12 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
 
@@ -33,7 +33,7 @@ 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);
 

	
spectrum/src/main.cpp
Show inline comments
 
@@ -131,6 +131,32 @@ static void daemonize(const char *cwd, const char *lock_file) {
 
}
 
#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
 
@@ -400,7 +426,7 @@ int main(int argc, char **argv)
 

	
 
	// 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";
src/util.cpp
Show inline comments
 
@@ -49,7 +49,7 @@ 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;
 
	}
0 comments (0 inline, 0 general)