Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -331,11 +331,11 @@ AC_SUBST(AUTORELEASE_M, "autorelease.m") ]) AC_CHECK_FUNC(objc_enumerationMutation, [ AC_DEFINE(HAVE_OBJC_ENUMERATIONMUTATION, 1, - [Whether we have objc_enumerationMutation]) + [Whether we have objc_enumerationMutation()]) ]) case "$host_os" in darwin*) AC_SUBST(LDFLAGS_REEXPORT, ["-Wl,-reexport-lobjfw"]) @@ -417,11 +417,11 @@ ac_cv_snprintf_useful_ret="yes" ;; *) have_asprintf="yes" AC_DEFINE(OF_HAVE_ASPRINTF, 1, - [Whether we have asprintf]) + [Whether we have asprintf()]) AC_SUBST(ASPRINTF_DEF, "-DOF_HAVE_ASPRINTF") ;; esac ], [ have_asprintf="no" @@ -491,11 +491,11 @@ [Whether we have pthread spinlocks]) ]) AC_CHECK_FUNC(sched_yield, [ AC_DEFINE(OF_HAVE_SCHED_YIELD, 1, - [Whether we have sched_yield]) + [Whether we have sched_yield()]) ]) ], [ AC_MSG_ERROR(No supported threads found!) ]) ;; @@ -572,10 +572,24 @@ AC_SUBST(ATOMIC_H, "atomic.h") ]) AC_MSG_RESULT($atomic_ops) AC_CHECK_FUNCS([gmtime_r localtime_r nanosleep]) + +AC_CHECK_HEADERS([pwd.h grp.h]) +AC_CHECK_FUNC(chmod, [ + AC_DEFINE(OF_HAVE_CHMOD, 1, [Whether we have chmod()]) +]) +AC_CHECK_FUNC(chown, [ + AC_DEFINE(OF_HAVE_CHOWN, 1, [Whether we have chown()]) +]) +AC_CHECK_FUNC(link, [ + AC_DEFINE(OF_HAVE_LINK, 1, [Whether we have link()]) +]) +AC_CHECK_FUNC(symlink, [ + AC_DEFINE(OF_HAVE_SYMLINK, 1, [Whether we have symlink()]) +]) AC_ARG_ENABLE(sockets, AS_HELP_STRING([--disable-sockets], [disable socket support])) AS_IF([test x"$enable_sockets" != x"no"], [ AC_DEFINE(OF_HAVE_SOCKETS, 1, [Whether we have sockets]) @@ -618,11 +632,11 @@ ], [ struct addrinfo ai; getaddrinfo(NULL, NULL, NULL, NULL); ], [ AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_GETADDRINFO, 1, [Whether we have getaddrinfo]) + AC_DEFINE(HAVE_GETADDRINFO, 1, [Whether we have getaddrinfo()]) AS_IF([test x"$enable_threads" != x"no"], [ AC_MSG_CHECKING(whether getaddrinfo is thread-safe) case "$host_os" in Index: src/OFFile.h ================================================================== --- src/OFFile.h +++ src/OFFile.h @@ -146,11 +146,11 @@ * * @return The date of the last modification of the file */ + (OFDate*)modificationDateOfFileAtPath: (OFString*)path; -#ifndef _PSP +#ifdef OF_HAVE_CHMOD /*! * @brief Changes the mode of a file. * * Only changes read-only flag on Windows. * @@ -160,11 +160,11 @@ */ + (void)changeModeOfFileAtPath: (OFString*)path mode: (mode_t)mode; #endif -#if !defined(_WIN32) && !defined(_PSP) +#ifdef OF_HAVE_CHOWN /*! * @brief Changes the owner of a file. * * Not available on Windows. * @@ -208,11 +208,11 @@ * * @param path The path to the directory which should be deleted as a string */ + (void)deleteDirectoryAtPath: (OFString*)path; -#ifndef _WIN32 +#ifdef OF_HAVE_LINK /*! * @brief Creates a hard link for a file. * * Not available on Windows. * @@ -221,11 +221,11 @@ */ + (void)linkFileAtPath: (OFString*)source toPath: (OFString*)destination; #endif -#if !defined(_WIN32) && !defined(_PSP) +#ifdef OF_HAVE_SYMLINK /*! * @brief Creates a symbolink link for a file. * * Not available on Windows. * Index: src/OFFile.m ================================================================== --- src/OFFile.m +++ src/OFFile.m @@ -33,12 +33,14 @@ #include #include #include #include -#ifndef _WIN32 +#ifdef HAVE_PWD_H # include +#endif +#ifdef HAVE_GRP_H # include #endif #import "OFFile.h" #import "OFString.h" @@ -99,11 +101,11 @@ OFStream *of_stdin = nil; OFStream *of_stdout = nil; OFStream *of_stderr = nil; -#if defined(OF_HAVE_THREADS) && !defined(_WIN32) +#if defined(OF_HAVE_CHOWN) && defined(OF_HAVE_THREADS) static of_mutex_t mutex; #endif static int parse_mode(const char *mode) { @@ -160,11 +162,11 @@ @interface OFFileSingleton: OFFile @end @implementation OFFile -#if defined(OF_HAVE_THREADS) && !defined(_WIN32) +#if defined(OF_HAVE_CHOWN) && defined(OF_HAVE_THREADS) + (void)initialize { if (self != [OFFile class]) return; @@ -387,11 +389,11 @@ @throw [OFChangeDirectoryFailedException exceptionWithClass: self path: path]; } -#ifndef _PSP +#ifdef OF_HAVE_CHMOD + (void)changeModeOfFileAtPath: (OFString*)path mode: (mode_t)mode { # ifndef _WIN32 if (chmod([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE], mode)) @@ -444,11 +446,11 @@ /* FIXME: We could be more precise on some OSes */ return [OFDate dateWithTimeIntervalSince1970: s.st_mtime]; } -#if !defined(_WIN32) && !defined(_PSP) +#ifdef OF_HAVE_CHOWN + (void)changeOwnerOfFileAtPath: (OFString*)path owner: (OFString*)owner group: (OFString*)group { uid_t uid = -1; @@ -545,11 +547,11 @@ length: pageSize]; [destinationFile writeBuffer: buffer length: length]; } -#if !defined(_WIN32) && !defined(_PSP) +#ifdef OF_HAVE_CHMOD if (!override) { struct stat s; if (fstat(sourceFile->_fd, &s) == 0) fchmod(destinationFile->_fd, s.st_mode); @@ -612,11 +614,11 @@ @throw [OFDeleteDirectoryFailedException exceptionWithClass: self path: path]; } -#ifndef _WIN32 +#ifdef OF_HAVE_LINK + (void)linkFileAtPath: (OFString*)source toPath: (OFString*)destination { void *pool = objc_autoreleasePoolPush(); @@ -634,11 +636,11 @@ objc_autoreleasePoolPop(pool); } #endif -#if !defined(_WIN32) && !defined(_PSP) +#ifdef OF_HAVE_SYMLINK + (void)symlinkFileAtPath: (OFString*)source toPath: (OFString*)destination { void *pool = objc_autoreleasePoolPush(); Index: src/OFThread.m ================================================================== --- src/OFThread.m +++ src/OFThread.m @@ -16,10 +16,11 @@ #include "config.h" #define OF_THREAD_M +#define _POSIX_TIMERS #define __NO_EXT_QNX #include #include #include Index: src/objfw-defs.h.in ================================================================== --- src/objfw-defs.h.in +++ src/objfw-defs.h.in @@ -1,20 +1,24 @@ #undef OF_APPLE_RUNTIME #undef OF_BIG_ENDIAN #undef OF_FLOAT_BIG_ENDIAN #undef OF_HAVE_ASPRINTF #undef OF_HAVE_ATOMIC_OPS +#undef OF_HAVE_CHMOD +#undef OF_HAVE_CHOWN #undef OF_HAVE_COMPILER_TLS #undef OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR #undef OF_HAVE_GCC_ATOMIC_OPS +#undef OF_HAVE_LINK #undef OF_HAVE_OSATOMIC #undef OF_HAVE_OSATOMIC_64 #undef OF_HAVE_PTHREADS #undef OF_HAVE_PLUGINS #undef OF_HAVE_PROCESSES #undef OF_HAVE_PTHREAD_SPINLOCKS #undef OF_HAVE_RECURSIVE_PTHREAD_MUTEXES #undef OF_HAVE_SCHED_YIELD #undef OF_HAVE_SOCKETS +#undef OF_HAVE_SYMLINK #undef OF_HAVE_THREADS #undef OF_OBJFW_RUNTIME #undef SIZE_MAX