Remove the build platform work-arounds

This commit is contained in:
Ingo Weinhold 2011-06-30 19:19:03 +02:00
parent e954868b70
commit bd530a0800

View File

@ -41,74 +41,7 @@ using BPrivate::FileDescriptorCloser;
static const char* const kPublicDomainLicenseName = "Public Domain";
// We need to remap a few file operations on non-Haiku platforms, so dealing
// with symlinks works correctly.
#ifndef __HAIKU__
extern "C" int _kern_open(int fd, const char *path, int openMode, int perms);
extern "C" status_t _kern_close(int fd);
extern "C" status_t _kern_read_stat(int fd, const char *path, bool traverseLink,
struct stat *st, size_t statSize);
static int
build_openat(int dirFD, const char* fileName, int openMode, int permissions)
{
int fd = _kern_open(dirFD, fileName, openMode, permissions);
if (fd < 0) {
errno = fd;
return -1;
}
return fd;
}
static int
build_fstat(int fd, struct stat* st)
{
status_t error = _kern_read_stat(fd, NULL, false, st, sizeof(struct stat));
if (error != B_OK) {
errno = error;
return -1;
}
return 0;
}
struct BuildFileDescriptorCloser {
BuildFileDescriptorCloser(int fd)
:
fFD(fd)
{
}
~BuildFileDescriptorCloser()
{
if (fFD >= 0)
_kern_close(fFD);
}
private:
int fFD;
};
#undef openat
#define openat(dirFD, fileName, openMode) \
build_openat(dirFD, fileName, openMode, 0)
#undef fstat
#define fstat(fd, st) build_fstat(fd, st)
#undef FileDescriptorCloser
#define FileDescriptorCloser BuildFileDescriptorCloser
#endif
#include <typeinfo>
namespace BPackageKit {