From 0b3a25080b95770f5447a0dbde4625d122b31fb3 Mon Sep 17 00:00:00 2001 From: ai4rei Date: Tue, 30 Nov 2010 18:02:54 +0000 Subject: * Moved function 'exists' (file presense check) to utils.c, so that it is available to code outside of lock.c - Fixed associated F_OK and R_OK defines causing 'already defined' warnings on MinGW (since r1361). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14528 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/lock.c | 9 +++------ src/common/utils.c | 9 +++++++++ src/common/utils.h | 1 + 3 files changed, 13 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/common/lock.c b/src/common/lock.c index 5cb4c3a67..643b86e5c 100644 --- a/src/common/lock.c +++ b/src/common/lock.c @@ -1,8 +1,9 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include "../common/cbasetypes.h" -#include "../common/showmsg.h" +#include "cbasetypes.h" +#include "showmsg.h" +#include "utils.h" #include "lock.h" #include @@ -12,12 +13,8 @@ #include #else #include -#define F_OK 0x0 -#define R_OK 0x4 #endif -#define exists(filename) (!access(filename, F_OK)) - // 書き込みファイルの保護処理 // (書き込みが終わるまで、旧ファイルを保管しておく) diff --git a/src/common/utils.c b/src/common/utils.c index c1128edb4..12123784f 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -14,7 +14,11 @@ #include // floor() #ifdef WIN32 + #include #include + #ifndef F_OK + #define F_OK 0x0 + #endif /* F_OK */ #else #include #include @@ -182,6 +186,11 @@ void findfile(const char *p, const char *pat, void (func)(const char*)) } #endif +bool exists(const char* filename) +{ + return !access(filename, F_OK); +} + uint8 GetByte(uint32 val, int idx) { switch( idx ) diff --git a/src/common/utils.h b/src/common/utils.h index 93563dc34..5cf3ff3cf 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -14,6 +14,7 @@ void dump(FILE* fp, const unsigned char* buffer, int length); void findfile(const char *p, const char *pat, void (func)(const char*)); +bool exists(const char* filename); //Caps values to min/max #define cap_value(a, min, max) ((a >= max) ? max : (a <= min) ? min : a) -- cgit v1.2.3-70-g09d2