* wince/sys : add stat.c, stat.h, timeb.c, timeb.h,
types.h, utime.c, utime.h * wince/dll.mak : object file name changed. * wince/io.c : add empty dup2(). * wince/io.h : add dup2 definition. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3146 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c79e877836
commit
009f78761d
@ -1,3 +1,11 @@
|
||||
Sat Dec 14 14:25:00 2002 Takaaki Uematsu <mail@uema2.cjb.net>
|
||||
|
||||
* wince/sys : add stat.c, stat.h, timeb.c, timeb.h,
|
||||
types.h, utime.c, utime.h
|
||||
* wince/dll.mak : object file name changed.
|
||||
* wince/io.c : add empty dup2().
|
||||
* wince/io.h : add dup2 definition.
|
||||
|
||||
Sat Dec 14 01:51:29 2002 WATANABE Hirofumi <eban@ruby-lang.org>
|
||||
|
||||
* ext/dbm/extconf.rb (rb_check): support for GNU dbm 1.8.3.
|
||||
|
@ -68,7 +68,6 @@ CLEAN :
|
||||
-@erase "$(INTDIR)\dir.obj"
|
||||
-@erase "$(INTDIR)\dln.obj"
|
||||
-@erase "$(INTDIR)\dmyext.obj"
|
||||
-@erase "$(INTDIR)\dup2.obj"
|
||||
-@erase "$(INTDIR)\enum.obj"
|
||||
-@erase "$(INTDIR)\error.obj"
|
||||
-@erase "$(INTDIR)\eval.obj"
|
||||
@ -108,7 +107,7 @@ CLEAN :
|
||||
-@erase "$(OUTDIR)\mswince_ruby17.lib"
|
||||
-@erase "$(OUTDIR)\wce\direct.obj"
|
||||
-@erase "$(OUTDIR)\wce\errno.obj"
|
||||
-@erase "$(OUTDIR)\wce\ceio.obj"
|
||||
-@erase "$(OUTDIR)\wce\io.obj"
|
||||
-@erase "$(OUTDIR)\wce\parse.obj"
|
||||
-@erase "$(OUTDIR)\wce\process.obj"
|
||||
-@erase "$(OUTDIR)\wce\signal.obj"
|
||||
@ -116,7 +115,7 @@ CLEAN :
|
||||
-@erase "$(OUTDIR)\wce\stdio.obj"
|
||||
-@erase "$(OUTDIR)\wce\stdlib.obj"
|
||||
-@erase "$(OUTDIR)\wce\string.obj"
|
||||
-@erase "$(OUTDIR)\wce\cetime.obj"
|
||||
-@erase "$(OUTDIR)\wce\time.obj"
|
||||
-@erase "$(OUTDIR)\wce\timeb.obj"
|
||||
-@erase "$(OUTDIR)\wce\utime.obj"
|
||||
-@erase "$(OUTDIR)\wce\wince.obj"
|
||||
@ -213,7 +212,6 @@ LINK32_OBJS= \
|
||||
"$(INTDIR)\win32.obj" \
|
||||
"$(INTDIR)\acosh.obj" \
|
||||
"$(INTDIR)\crypt.obj" \
|
||||
"$(INTDIR)\dup2.obj" \
|
||||
"$(INTDIR)\hypot.obj" \
|
||||
"$(INTDIR)\isinf.obj" \
|
||||
"$(INTDIR)\isnan.obj" \
|
||||
@ -260,7 +258,6 @@ CLEAN :
|
||||
-@erase "$(INTDIR)\dir.obj"
|
||||
-@erase "$(INTDIR)\dln.obj"
|
||||
-@erase "$(INTDIR)\dmyext.obj"
|
||||
-@erase "$(INTDIR)\dup2.obj"
|
||||
-@erase "$(INTDIR)\enum.obj"
|
||||
-@erase "$(INTDIR)\error.obj"
|
||||
-@erase "$(INTDIR)\eval.obj"
|
||||
@ -405,7 +402,6 @@ LINK32_OBJS= \
|
||||
"$(INTDIR)\win32.obj" \
|
||||
"$(INTDIR)\acosh.obj" \
|
||||
"$(INTDIR)\crypt.obj" \
|
||||
"$(INTDIR)\dup2.obj" \
|
||||
"$(INTDIR)\hypot.obj" \
|
||||
"$(INTDIR)\isinf.obj" \
|
||||
"$(INTDIR)\isnan.obj" \
|
||||
@ -452,7 +448,6 @@ CLEAN :
|
||||
-@erase "$(INTDIR)\dir.obj"
|
||||
-@erase "$(INTDIR)\dln.obj"
|
||||
-@erase "$(INTDIR)\dmyext.obj"
|
||||
-@erase "$(INTDIR)\dup2.obj"
|
||||
-@erase "$(INTDIR)\enum.obj"
|
||||
-@erase "$(INTDIR)\error.obj"
|
||||
-@erase "$(INTDIR)\eval.obj"
|
||||
@ -597,7 +592,6 @@ LINK32_OBJS= \
|
||||
"$(INTDIR)\win32.obj" \
|
||||
"$(INTDIR)\acosh.obj" \
|
||||
"$(INTDIR)\crypt.obj" \
|
||||
"$(INTDIR)\dup2.obj" \
|
||||
"$(INTDIR)\hypot.obj" \
|
||||
"$(INTDIR)\isinf.obj" \
|
||||
"$(INTDIR)\isnan.obj" \
|
||||
@ -644,7 +638,6 @@ CLEAN :
|
||||
-@erase "$(INTDIR)\dir.obj"
|
||||
-@erase "$(INTDIR)\dln.obj"
|
||||
-@erase "$(INTDIR)\dmyext.obj"
|
||||
-@erase "$(INTDIR)\dup2.obj"
|
||||
-@erase "$(INTDIR)\enum.obj"
|
||||
-@erase "$(INTDIR)\error.obj"
|
||||
-@erase "$(INTDIR)\eval.obj"
|
||||
@ -789,7 +782,6 @@ LINK32_OBJS= \
|
||||
"$(INTDIR)\win32.obj" \
|
||||
"$(INTDIR)\acosh.obj" \
|
||||
"$(INTDIR)\crypt.obj" \
|
||||
"$(INTDIR)\dup2.obj" \
|
||||
"$(INTDIR)\hypot.obj" \
|
||||
"$(INTDIR)\isinf.obj" \
|
||||
"$(INTDIR)\isnan.obj" \
|
||||
@ -1186,9 +1178,6 @@ LINK32_OBJS= \
|
||||
".\config.h"\
|
||||
".\wince.h"\
|
||||
|
||||
..\missing\dup2.c : \
|
||||
".\config.h"\
|
||||
|
||||
..\missing\isinf.c : \
|
||||
".\config.h"\
|
||||
|
||||
@ -1427,11 +1416,6 @@ SOURCE=..\missing\crypt.c
|
||||
"$(INTDIR)\crypt.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
SOURCE=..\missing\dup2.c
|
||||
|
||||
"$(INTDIR)\dup2.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
SOURCE=..\missing\hypot.c
|
||||
|
||||
"$(INTDIR)\hypot.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
@ -183,12 +183,20 @@ int _chmod(const char *path, int mode)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* WinCE doesn't have dup and dup2. */
|
||||
/* so, we cannot use missing/dup2.c. */
|
||||
int _dup( int handle )
|
||||
{
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int dup2( int handle1, int handle2 )
|
||||
{
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _isatty(int fd)
|
||||
{
|
||||
if( fd==(int)_fileno(stdin) ||
|
||||
|
@ -30,6 +30,7 @@ int _unlink(const char *file);
|
||||
int _umask(int cmask);
|
||||
int _chmod(const char *path, int mode);
|
||||
int _dup( int handle );
|
||||
int dup2( int handle1, int handle2 );
|
||||
int _isatty(int fd);
|
||||
int _pipe(int *phandles, unsigned int psize, int textmode);
|
||||
int _access(const char *filename, int flags);
|
||||
|
101
wince/sys/stat.c
Normal file
101
wince/sys/stat.c
Normal file
@ -0,0 +1,101 @@
|
||||
/***************************************************************
|
||||
stat.c
|
||||
|
||||
author : uema2
|
||||
date : Nov 30, 2002
|
||||
|
||||
You can freely use, copy, modify, and redistribute
|
||||
the whole contents.
|
||||
***************************************************************/
|
||||
|
||||
#include <windows.h>
|
||||
#include <sys/stat.h>
|
||||
#include <time.h>
|
||||
#include "..\wince.h" /* for wce_mbtowc */
|
||||
|
||||
|
||||
int _stat(const char *filename, struct _stat *st)
|
||||
{
|
||||
DWORD dwAttribute;
|
||||
HANDLE h;
|
||||
DWORD dwSizeLow=0, dwSizeHigh=0, dwError=0;
|
||||
WIN32_FIND_DATAW fd;
|
||||
wchar_t *wfilename;
|
||||
|
||||
wfilename = wce_mbtowc(filename);
|
||||
|
||||
dwAttribute = GetFileAttributesW(wfilename);
|
||||
if(dwAttribute==0xFFFFFFFF)
|
||||
{
|
||||
free(wfilename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
st->st_mode = 0;
|
||||
if((dwAttribute & FILE_ATTRIBUTE_DIRECTORY) != 0)
|
||||
st->st_mode += S_IFDIR;
|
||||
else
|
||||
st->st_mode += S_IFREG;
|
||||
|
||||
/* initialize */
|
||||
st->st_atime = 0;
|
||||
st->st_mtime = 0;
|
||||
st->st_ctime = 0;
|
||||
st->st_size = 0;
|
||||
st->st_dev = 0;
|
||||
|
||||
h = FindFirstFileW(wfilename, &fd);
|
||||
if(h == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
if(wfilename[wcslen(wfilename)-1] == L'\\')
|
||||
{
|
||||
wfilename[wcslen(wfilename)-1] = L'\0';
|
||||
h = FindFirstFileW(wfilename, &fd);
|
||||
if(h == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
free(wfilename);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
free(wfilename);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* FILETIME -> time_t */
|
||||
st->st_atime = wce_FILETIME2time_t(&fd.ftLastAccessTime);
|
||||
st->st_mtime = wce_FILETIME2time_t(&fd.ftLastWriteTime);
|
||||
st->st_ctime = wce_FILETIME2time_t(&fd.ftCreationTime);
|
||||
st->st_size = fd.nFileSizeLow;
|
||||
|
||||
FindClose( h );
|
||||
free(wfilename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fstat(int file, struct stat *sbuf)
|
||||
{
|
||||
/* GetFileSize & GetFileTime */
|
||||
DWORD dwSize;
|
||||
FILETIME ctime, atime, mtime;
|
||||
|
||||
dwSize = GetFileSize( (HANDLE)file, NULL );
|
||||
if( dwSize == 0xFFFFFFFF )
|
||||
return -1;
|
||||
|
||||
sbuf->st_size = dwSize;
|
||||
sbuf->st_dev = 0;
|
||||
sbuf->st_rdev = 0;
|
||||
sbuf->st_mode = _S_IFREG;
|
||||
sbuf->st_nlink= 1;
|
||||
|
||||
GetFileTime( (HANDLE)file, &ctime, &atime, &mtime );
|
||||
sbuf->st_ctime = wce_FILETIME2time_t(&ctime);
|
||||
sbuf->st_atime = wce_FILETIME2time_t(&atime);
|
||||
sbuf->st_mtime = wce_FILETIME2time_t(&mtime);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
68
wince/sys/stat.h
Normal file
68
wince/sys/stat.h
Normal file
@ -0,0 +1,68 @@
|
||||
#ifndef SYS_STAT_H
|
||||
#define SYS_STAT_H 1
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#define _S_IFMT 0170000 /* file type mask */
|
||||
#define _S_IFDIR 0040000 /* directory */
|
||||
#define _S_IFCHR 0020000 /* character special */
|
||||
#define _S_IFIFO 0010000 /* pipe */
|
||||
#define _S_IFREG 0100000 /* regular */
|
||||
#define _S_IREAD 0000400 /* read permission, owner */
|
||||
#define _S_IWRITE 0000200 /* write permission, owner */
|
||||
#define _S_IEXEC 0000100 /* execute/search permission, owner */
|
||||
|
||||
#define S_IFMT _S_IFMT
|
||||
#define S_IFREG _S_IFREG
|
||||
#define S_IFCHR _S_IFCHR
|
||||
#define S_IFDIR _S_IFDIR
|
||||
#define S_IREAD _S_IREAD
|
||||
#define S_IWRITE _S_IWRITE
|
||||
#define S_IEXEC _S_IEXEC
|
||||
|
||||
#ifndef S_ISDIR
|
||||
#define S_ISDIR(X) (((X) & S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
#ifndef S_ISREG
|
||||
#define S_ISREG(X) (((X) & S_IFMT) == S_IFREG)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// in sys/types.h
|
||||
//typedef unsigned int _dev_t;
|
||||
//typedef long _off_t;
|
||||
//typedef unsigned short _ino_t;
|
||||
|
||||
#ifndef _STAT_DEFINED
|
||||
struct stat
|
||||
{
|
||||
dev_t st_dev;
|
||||
ino_t st_ino;
|
||||
unsigned short st_mode;
|
||||
short st_nlink;
|
||||
short st_uid;
|
||||
short st_gid;
|
||||
dev_t st_rdev;
|
||||
off_t st_size;
|
||||
time_t st_atime;
|
||||
time_t st_mtime;
|
||||
time_t st_ctime;
|
||||
};
|
||||
#define _STAT_DEFINED
|
||||
#endif /* _STAT_DEFINED */
|
||||
|
||||
#define _stat stat
|
||||
|
||||
int _stat(const char *filename, struct _stat *stat);
|
||||
int fstat(int file, struct stat *sbuf);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
25
wince/sys/timeb.c
Normal file
25
wince/sys/timeb.c
Normal file
@ -0,0 +1,25 @@
|
||||
/***************************************************************
|
||||
timeb.c
|
||||
***************************************************************/
|
||||
|
||||
#include <windows.h>
|
||||
#include <time.h>
|
||||
#include <sys/timeb.h>
|
||||
|
||||
|
||||
int ftime(struct timeb *tp)
|
||||
{
|
||||
SYSTEMTIME s;
|
||||
FILETIME f;
|
||||
|
||||
GetLocalTime(&s);
|
||||
SystemTimeToFileTime( &s, &f );
|
||||
|
||||
tp->dstflag = 0;
|
||||
tp->timezone = _timezone/60;
|
||||
tp->time = wce_FILETIME2time_t(&f);
|
||||
tp->millitm = s.wMilliseconds;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
26
wince/sys/timeb.h
Normal file
26
wince/sys/timeb.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef SYS_TIMEB_H
|
||||
#define SYS_TIMEB_H 1
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
struct _timeb {
|
||||
time_t time;
|
||||
unsigned short millitm;
|
||||
short timezone;
|
||||
short dstflag;
|
||||
};
|
||||
|
||||
#define timeb _timeb
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int ftime(struct timeb *tp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
67
wince/sys/types.h
Normal file
67
wince/sys/types.h
Normal file
@ -0,0 +1,67 @@
|
||||
#ifndef SYS_TYPES_H
|
||||
#define SYS_TYPES_H 1
|
||||
|
||||
#define BIG_ENDIAN 1234
|
||||
#define LITTLE_ENDIAN 4321
|
||||
|
||||
#ifdef MIPS
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
#endif
|
||||
|
||||
//#if UNDER_CE > 201
|
||||
// typedef unsigned long time_t;
|
||||
// #define _TIME_T_DEFINED_
|
||||
//#endif
|
||||
typedef unsigned long dev_t;
|
||||
typedef unsigned long ino_t;
|
||||
#ifndef _MODE_T_DEFINED_
|
||||
typedef unsigned long mode_t;
|
||||
#define _MODE_T_DEFINED_
|
||||
#endif
|
||||
|
||||
//typedef unsigned short gid_t;
|
||||
//typedef unsigned short uid_t;
|
||||
typedef long clock_t;
|
||||
|
||||
#ifndef _PTRDIFF_T_DEFINED
|
||||
typedef long ptrdiff_t;
|
||||
#define _PTRDIFF_T_DEFINED
|
||||
#endif
|
||||
|
||||
typedef long off_t;
|
||||
|
||||
//typedef unsigned char u_char;
|
||||
//typedef unsigned short u_short;
|
||||
|
||||
#ifndef _CADDR_T_DEFINED_
|
||||
typedef unsigned char * caddr_t;
|
||||
#define _CADDR_T_DEFINED_
|
||||
#endif
|
||||
|
||||
#ifndef _SIZE_T_DEFINED_
|
||||
typedef unsigned int size_t;
|
||||
#define _SIZE_T_DEFINED_
|
||||
#endif
|
||||
|
||||
//typedef unsigned char u_int8_t;
|
||||
|
||||
//typedef short int16_t;
|
||||
//typedef unsigned short u_int16_t;
|
||||
|
||||
//typedef int int32_t;
|
||||
//typedef unsigned int u_int32_t;
|
||||
|
||||
//typedef unsigned long u_long;
|
||||
//typedef unsigned int u_int;
|
||||
|
||||
//#ifndef _TIME_T_DEFINED_
|
||||
//typedef unsigned long time_t;
|
||||
//#define _TIME_T_DEFINED_
|
||||
//#endif
|
||||
|
||||
#ifndef _PID_T_DEFINED_
|
||||
typedef unsigned long pid_t;
|
||||
#define _PID_T_DEFINED_
|
||||
#endif
|
||||
|
||||
#endif
|
44
wince/sys/utime.c
Normal file
44
wince/sys/utime.c
Normal file
@ -0,0 +1,44 @@
|
||||
/***************************************************************
|
||||
utime.c
|
||||
***************************************************************/
|
||||
|
||||
#include <windows.h>
|
||||
#include <sys/utime.h>
|
||||
#include "..\wince.h" /* for wce_mbtowc */
|
||||
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
#if _WIN32_WCE < 300
|
||||
#define Int32x32To64(a, b) ((LONGLONG)((LONG)(a)) * (LONGLONG)((LONG)(b)))
|
||||
/* #define Int32x32To64(a, b) ((__int64)((LONG)(a)) * (__int64)((LONG)(b))) */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int _utime(const char *f, struct utimbuf *t)
|
||||
{
|
||||
HANDLE h;
|
||||
FILETIME atime={0}, mtime={0};
|
||||
__int64 time64;
|
||||
BOOL rc;
|
||||
wchar_t *w;
|
||||
|
||||
w = wce_mbtowc(f);
|
||||
h = CreateFileW(w, GENERIC_WRITE,
|
||||
FILE_SHARE_READ|FILE_SHARE_WRITE,
|
||||
NULL, OPEN_EXISTING, 0, 0);
|
||||
free(w);
|
||||
|
||||
if( h==INVALID_HANDLE_VALUE )
|
||||
return -1;
|
||||
|
||||
time64 = Int32x32To64(t->actime, 10000000) + 116444736000000000;
|
||||
atime.dwLowDateTime = (DWORD)time64;
|
||||
atime.dwHighDateTime = (DWORD)(time64 >> 32);
|
||||
time64 = Int32x32To64(t->modtime, 10000000) + 116444736000000000;
|
||||
mtime.dwLowDateTime = (DWORD)time64;
|
||||
mtime.dwHighDateTime = (DWORD)(time64 >> 32);
|
||||
|
||||
rc = SetFileTime(h, NULL, &atime, &mtime);
|
||||
return rc==TRUE ? 0 : -1;
|
||||
}
|
||||
|
27
wince/sys/utime.h
Normal file
27
wince/sys/utime.h
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef SYS_UTIME_H
|
||||
#define SYS_UTIME_H 1
|
||||
|
||||
#include <time.h>
|
||||
|
||||
struct utimbuf
|
||||
{
|
||||
time_t actime;
|
||||
time_t modtime;
|
||||
};
|
||||
|
||||
#define _utimbuf utimbuf
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int _utime(const char *f, struct utimbuf *t);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#define utime _utime
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user