14 extern char **environ
;
17 mono_wrapper_seek (gpointer fd
, gint64 offset
, gint32 whence
)
21 if (offset
> INT_MAX
|| offset
< INT_MIN
)
24 code
= lseek ((int)fd
, offset
, whence
);
32 mono_wrapper_read (gpointer fd
, void* buf
, gint32 count
)
34 int n
= read ((int)fd
, buf
, count
);
42 mono_wrapper_write (gpointer fd
, void* buf
, gint32 count
)
44 int n
= write ((int)fd
, buf
, count
);
52 mono_wrapper_fstat (gpointer fd
, MonoWrapperStat
* buf
)
56 if (fstat ((int)fd
, &fs
) == -1)
59 buf
->mst_dev
= fs
.st_dev
;
60 buf
->mst_mode
= fs
.st_mode
;
61 buf
->mst_nlink
= fs
.st_nlink
;
62 buf
->mst_uid
= fs
.st_uid
;
63 buf
->mst_gid
= fs
.st_gid
;
64 buf
->mst_size
= fs
.st_size
;
65 buf
->mst_atime
= fs
.st_atime
;
66 buf
->mst_mtime
= fs
.st_mtime
;
67 buf
->mst_ctime
= fs
.st_ctime
;
73 mono_wrapper_ftruncate (gpointer fd
, gint64 length
)
77 if (length
> INT_MAX
|| length
< INT_MIN
)
80 code
= ftruncate ((int)fd
, length
);
87 mono_wrapper_open (const char * path
, gint32 flags
, gint32 mode
)
89 return (gpointer
) open (path
, flags
, mode
);
93 mono_wrapper_close (gpointer fd
)
95 return close ((int)fd
);
99 mono_wrapper_stat (const char * path
, MonoWrapperStat
* buf
)
103 if (stat (path
, &fs
) != 0)
106 buf
->mst_dev
= fs
.st_dev
;
107 buf
->mst_mode
= fs
.st_mode
;
108 buf
->mst_nlink
= fs
.st_nlink
;
109 buf
->mst_uid
= fs
.st_uid
;
110 buf
->mst_gid
= fs
.st_gid
;
111 buf
->mst_size
= fs
.st_size
;
112 buf
->mst_atime
= fs
.st_atime
;
113 buf
->mst_mtime
= fs
.st_mtime
;
114 buf
->mst_ctime
= fs
.st_ctime
;
120 mono_wrapper_unlink (const char * path
)
122 if (unlink(path
) == -1)
128 mono_wrapper_opendir (const char * path
)
130 return (gpointer
)opendir(path
);
134 mono_wrapper_readdir (gpointer dir
)
138 p
= readdir((DIR*)dir
);
140 return p
!= NULL
? p
->d_name
: NULL
;
144 mono_wrapper_closedir (gpointer dir
)
146 return closedir((DIR*)dir
);
150 mono_wrapper_getenv (const char * variable
)
152 return (gpointer
)getenv(variable
);
156 mono_wrapper_environ ()
158 return (gpointer
)environ
;
162 mono_wrapper_mkdir (const char *path
, int mode
)
165 if (mkdir (path
, mode
) == -1)
172 mono_wrapper_rmdir (const char *path
)
174 if (rmdir (path
) == -1)
180 mono_wrapper_rename (const char *src
, const char *dst
)
182 if (rename (src
, dst
) == -1)
188 mono_wrapper_utime (const char *path
, int atime
, int mtime
)
196 if (utime (path
, &buf
) == -1)