From dc3744a71ca2db4a938ef0ae41ec551f708ceb02 Mon Sep 17 00:00:00 2001 From: Adam- Date: Tue, 25 May 2010 20:21:54 +0000 Subject: [PATCH] Check if a module file exists before making runtime copy of it, keeps 0 byte sized unused modules out of the runtime/ directory git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2984 5417fbe8-f217-4b02-8779-1006273d7864 --- src/modulemanager.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp index 0716e4503..c4bceb119 100644 --- a/src/modulemanager.cpp +++ b/src/modulemanager.cpp @@ -48,6 +48,9 @@ static int moduleCopyFile(const char *name, const char *output) strlcat(input, name, sizeof(input)); strlcat(input, MODULE_EXT, sizeof(input)); + if ((source = fopen(input, "rb")) == NULL) + return MOD_ERR_NOEXIST; + #ifndef _WIN32 if ((srcfp = mkstemp(const_cast(output))) == -1) return MOD_ERR_FILE_IO; @@ -58,16 +61,6 @@ static int moduleCopyFile(const char *name, const char *output) Alog(LOG_DEBUG) << "Runtime module location: " << output; - /* Linux/UNIX should ignore the b param, why do we still have seperate - * calls for it here? -GD - */ -#ifndef _WIN32 - if ((source = fopen(input, "r")) == NULL) { -#else - if ((source = fopen(input, "rb")) == NULL) { -#endif - return MOD_ERR_NOEXIST; - } #ifndef _WIN32 if ((target = fdopen(srcfp, "w")) == NULL) { #else