From 56511265eb4674f0b78b281e5aa8849036087b4f Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 11 Nov 2004 19:33:51 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=4526 --- lib/filesys.C | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/filesys.C b/lib/filesys.C index da62e54c88..07b8b2ba95 100755 --- a/lib/filesys.C +++ b/lib/filesys.C @@ -464,8 +464,16 @@ int boinc_make_dirs(const char* dirpath, const char* filepath) { int lock_file(char* filename) { int retval; - // some systems have both! -#if defined(HAVE_LOCKF) && !defined(__APPLE__) +#ifdef _WIN32 + HANDLE hfile = CreateFile( + filename, GENERIC_WRITE, + 0, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0 + ); + if (hfile == INVALID_HANDLE_VALUE) retval = 1; + else retval = 0; + +// some systems have both! +#elif defined(HAVE_LOCKF) && !defined(__APPLE__) int lock = open(filename, O_WRONLY|O_CREAT, 0644); retval = lockf(lock, F_TLOCK, 1); #elif HAVE_FLOCK @@ -476,14 +484,6 @@ int lock_file(char* filename) { no file lock mechanism #endif -#ifdef _WIN32 - HANDLE hfile = CreateFile( - filename, GENERIC_WRITE, - 0, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0 - ); - if (hfile == INVALID_HANDLE_VALUE) retval = 1; - else retval = 0; -#endif return retval; }