aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortuler <tuler>2005-01-24 10:19:49 +0000
committertuler <tuler>2005-01-24 10:19:49 +0000
commit2540f6cbdb94ba60fe2ef94f12fc85f60c8ce767 (patch)
treeef857b77f260ec9747cf1f8904ec73eeadcb03c5 /src
parent57d3fc1c31e1d14446b491b135505beed3f347c3 (diff)
downloadluafilesystem-2540f6cbdb94ba60fe2ef94f12fc85f60c8ce767.tar.gz
luafilesystem-2540f6cbdb94ba60fe2ef94f12fc85f60c8ce767.tar.bz2
luafilesystem-2540f6cbdb94ba60fe2ef94f12fc85f60c8ce767.zip
WIN32 details
Diffstat (limited to 'src')
-rw-r--r--src/lfs.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/lfs.c b/src/lfs.c
index 5e09823..8485ae1 100644
--- a/src/lfs.c
+++ b/src/lfs.c
@@ -10,7 +10,7 @@
10** lfs.touch (filepath [, atime [, mtime]]) 10** lfs.touch (filepath [, atime [, mtime]])
11** lfs.unlock (fh) 11** lfs.unlock (fh)
12** 12**
13** $Id: lfs.c,v 1.18 2005/01/21 10:19:04 tomas Exp $ 13** $Id: lfs.c,v 1.19 2005/01/24 10:19:49 tuler Exp $
14*/ 14*/
15 15
16#include <errno.h> 16#include <errno.h>
@@ -19,7 +19,7 @@
19#include <time.h> 19#include <time.h>
20#include <sys/stat.h> 20#include <sys/stat.h>
21 21
22#ifdef WIN32 22#ifdef _WIN32
23#include <direct.h> 23#include <direct.h>
24#include <io.h> 24#include <io.h>
25#include <sys/locking.h> 25#include <sys/locking.h>
@@ -117,13 +117,13 @@ static FILE *check_file (lua_State *L, int idx, const char *funcname) {
117*/ 117*/
118static int _file_lock (lua_State *L, FILE *fh, const char *mode, const long start, long len, const char *funcname) { 118static int _file_lock (lua_State *L, FILE *fh, const char *mode, const long start, long len, const char *funcname) {
119 int code; 119 int code;
120#ifdef WIN32 120#ifdef _WIN32
121 /* lkmode valid values are: 121 /* lkmode valid values are:
122 _LK_LOCK Locks the specified bytes. If the bytes cannot be locked, the program immediately tries again after 1 second. If, after 10 attempts, the bytes cannot be locked, the constant returns an error. 122 LK_LOCK Locks the specified bytes. If the bytes cannot be locked, the program immediately tries again after 1 second. If, after 10 attempts, the bytes cannot be locked, the constant returns an error.
123 _LK_NBLCK Locks the specified bytes. If the bytes cannot be locked, the constant returns an error. 123 LK_NBLCK Locks the specified bytes. If the bytes cannot be locked, the constant returns an error.
124 _LK_NBRLCK Same as _LK_NBLCK. 124 LK_NBRLCK Same as _LK_NBLCK.
125 _LK_RLCK Same as _LK_LOCK. 125 LK_RLCK Same as _LK_LOCK.
126 _LK_UNLCK Unlocks the specified bytes, which must have been previously locked. 126 LK_UNLCK Unlocks the specified bytes, which must have been previously locked.
127 127
128 Regions should be locked only briefly and should be unlocked before closing a file or exiting the program. 128 Regions should be locked only briefly and should be unlocked before closing a file or exiting the program.
129 129
@@ -131,9 +131,9 @@ static int _file_lock (lua_State *L, FILE *fh, const char *mode, const long star
131 */ 131 */
132 int lkmode; 132 int lkmode;
133 switch (*mode) { 133 switch (*mode) {
134 case 'r': lkmode = _LK_NBLCK; break; 134 case 'r': lkmode = LK_NBLCK; break;
135 case 'w': lkmode = _LK_NBLCK; break; 135 case 'w': lkmode = LK_NBLCK; break;
136 case 'u': lkmode = _LK_UNLCK; break; 136 case 'u': lkmode = LK_UNLCK; break;
137 default : return luaL_error (L, "%s: invalid mode", funcname); 137 default : return luaL_error (L, "%s: invalid mode", funcname);
138 } 138 }
139 if (!len) { 139 if (!len) {
@@ -208,7 +208,7 @@ static void cgilua_sleep( lua_State *L )
208{ 208{
209 unsigned int usec = (unsigned int)luaL_check_number( L, 1 ); 209 unsigned int usec = (unsigned int)luaL_check_number( L, 1 );
210 210
211#ifndef WIN32 211#ifndef _WIN32
212 sleep( (unsigned int)ceil( usec/1000.0 )); 212 sleep( (unsigned int)ceil( usec/1000.0 ));
213#else 213#else
214 Sleep( (DWORD)usec ); 214 Sleep( (DWORD)usec );
@@ -233,7 +233,7 @@ static void cgilua_filesize( lua_State *L )
233static int make_dir (lua_State *L) { 233static int make_dir (lua_State *L) {
234 const char *path = luaL_checkstring (L, 1); 234 const char *path = luaL_checkstring (L, 1);
235 int fail; 235 int fail;
236#ifdef WIN32 236#ifdef _WIN32
237 int oldmask = umask (0); 237 int oldmask = umask (0);
238 fail = _mkdir (path); 238 fail = _mkdir (path);
239#else 239#else
@@ -373,7 +373,7 @@ static int dir_create_meta (lua_State *L) {
373/* 373/*
374** Convert the inode protection mode to a string. 374** Convert the inode protection mode to a string.
375*/ 375*/
376#ifdef WIN32 376#ifdef _WIN32
377static const char *mode2string (unsigned short mode) { 377static const char *mode2string (unsigned short mode) {
378#else 378#else
379static const char *mode2string (mode_t mode) { 379static const char *mode2string (mode_t mode) {
@@ -478,7 +478,7 @@ static int file_info (lua_State *L) {
478 lua_pushliteral (L, "size"); 478 lua_pushliteral (L, "size");
479 lua_pushnumber (L, (lua_Number)info.st_size); 479 lua_pushnumber (L, (lua_Number)info.st_size);
480 lua_rawset (L, -3); 480 lua_rawset (L, -3);
481#ifndef WIN32 481#ifndef _WIN32
482 /* blocks allocated for file */ 482 /* blocks allocated for file */
483 lua_pushliteral (L, "blocks"); 483 lua_pushliteral (L, "blocks");
484 lua_pushnumber (L, (lua_Number)info.st_blocks); 484 lua_pushnumber (L, (lua_Number)info.st_blocks);