Commit 6e09114d authored by sof's avatar sof
Browse files

[project @ 2001-11-07 07:57:57 by sof]

Wrapper functions reqd to implement Directory
parent f7b90904
/*
* (c) The GRASP/AQUA Project, Glasgow University, 1994-
*
* Directory Runtime Support
*/
#include "dirUtils.h"
#if defined(mingw32_TARGET_OS)
#include <windows.h>
#include <stdlib.h>
#endif
HsInt
prel_mkdir(HsAddr pathName, HsInt mode)
{
#if defined(mingw32_TARGET_OS)
return mkdir(pathName);
#else
return mkdir(pathName,mode);
#endif
}
HsInt
prel_lstat(HsAddr fname, HsAddr st)
{
#ifdef HAVE_LSTAT
return lstat((const char*)fname, (struct stat*)st);
#else
return stat((const char*)fname, (struct stat*)st);
#endif
}
HsInt prel_s_ISDIR(mode_t m) {return S_ISDIR(m);}
HsInt prel_s_ISREG(mode_t m) {return S_ISREG(m);}
HsInt prel_sz_stat() { return sizeof(struct stat); }
HsInt prel_path_max() { return PATH_MAX; }
mode_t prel_R_OK() { return R_OK; }
mode_t prel_W_OK() { return W_OK; }
mode_t prel_X_OK() { return X_OK; }
mode_t prel_S_IRUSR() { return S_IRUSR; }
mode_t prel_S_IWUSR() { return S_IWUSR; }
mode_t prel_S_IXUSR() { return S_IXUSR; }
time_t prel_st_mtime(struct stat* st) { return st->st_mtime; }
mode_t prel_st_mode(struct stat* st) { return st->st_mode; }
HsAddr prel_d_name(struct dirent* d)
{
#ifndef mingw32_TARGET_OS
return (HsAddr)((char*)d + (long)offsetof(struct dirent,d_name));
#else
return (HsAddr)(d->d_name);
#endif
}
HsInt prel_end_of_dir()
{
#ifndef mingw32_TARGET_OS
return EOK;
#else
return ENOENT;
#endif
}
/*
* (c) The GRASP/AQUA Project, Glasgow University, 1994-
*
* Directory Runtime Support - prototypes.
*/
#ifndef __DIRUTILS_H__
#define __DIRUTILS_H__
#include "HsStd.h"
#include <sys/stat.h>
#include <dirent.h>
#include <limits.h>
#include <errno.h>
#include <unistd.h>
extern HsInt prel_mkdir(HsAddr pathName, HsInt mode);
extern HsInt prel_lstat(HsAddr fname, HsAddr st);
extern HsInt prel_s_ISDIR(mode_t m);
extern HsInt prel_s_ISREG(mode_t m);
extern HsInt prel_sz_stat();
extern HsInt prel_path_max();
extern mode_t prel_R_OK();
extern mode_t prel_W_OK();
extern mode_t prel_X_OK();
extern mode_t prel_S_IRUSR();
extern mode_t prel_S_IWUSR();
extern mode_t prel_S_IXUSR();
extern time_t prel_st_mtime(struct stat* st);
extern mode_t prel_st_mode(struct stat* st);
extern HsAddr prel_d_name(struct dirent* d);
extern HsInt prel_end_of_dir();
#endif /* __DIRUTILS_H__ */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment