Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -51,10 +51,12 @@ AC_SUBST(AMIGA_LIB_LDFLAGS, "-mcpu=68020 -fbaserel -resident -nostartfiles") ]) ;; powerpc-*-amigaos*) + LIBS="$LIBS -lauto" + enable_shared="no" enable_threads="no" ;; *-morphos*) AS_IF([test x"$with_ixemul" != x"yes"], [ Index: src/OFApplication.m ================================================================== --- src/OFApplication.m +++ src/OFApplication.m @@ -52,10 +52,11 @@ #elif defined(OF_WINDOWS) # include extern int _CRT_glob; extern void __wgetmainargs(int *, wchar_t ***, wchar_t ***, int, int *); #elif defined(OF_AMIGAOS) +# define __USE_INLINE__ # include # include #elif !defined(OF_IOS) extern char **environ; #endif @@ -290,11 +291,15 @@ firstLocalVar = (struct LocalVar *)proc->pr_LocalVars.mlh_Head; for (struct LocalVar *iter = firstLocalVar; iter->lv_Node.ln_Succ != NULL; iter = (struct LocalVar *)iter->lv_Node.ln_Succ) { - size_t length; +# ifdef OF_AMIGAOS4 + int32 length; +# else + ULONG length; +# endif OFString *key, *value; if (iter->lv_Node.ln_Type != LV_VAR || iter->lv_Flags & GVF_BINARY_VAR) continue; Index: src/OFFile.m ================================================================== --- src/OFFile.m +++ src/OFFile.m @@ -56,10 +56,11 @@ # include # include #endif #ifdef OF_AMIGAOS +# define __USE_INLINE__ # include #endif #ifndef O_BINARY # define O_BINARY 0 @@ -272,13 +273,16 @@ mode: mode errNo: errNo]; } if (handle->append) { -# ifdef OF_MORPHOS +# if defined(OF_MORPHOS) if (Seek64(handle->handle, 0, OFFSET_END) == -1) { +# elif defined(OF_AMIGAOS4) + if (ChangeFilePosition(handle->handle, 0, + OFFSET_END) == -1) { # else if (Seek(handle->handle, 0, OFFSET_END) == -1) { # endif Close(handle->handle); @throw [OFOpenItemFailedException @@ -414,12 +418,14 @@ if (length > LONG_MAX) @throw [OFOutOfRangeException exception]; if (_handle->append) { -# ifdef OF_MORPHOS +# if defined(OF_MORPHOS) if (Seek64(_handle->handle, 0, OFFSET_END) == -1) +# elif defined(OF_AMIGAOS4) + if (ChangeFilePosition(_handle->handle, 0, OFFSET_END) == -1) # else if (Seek(_handle->handle, 0, OFFSET_END) == -1) # endif @throw [OFWriteFailedException exceptionWithObject: self @@ -489,12 +495,15 @@ offset: offset whence: whence errNo: EINVAL]; } -# ifdef OF_MORPHOS +# if defined(OF_MORPHOS) if ((ret = Seek64(_handle->handle, offset, translatedWhence)) == 1) +# elif defined(OF_AMIGAOS4) + if ((ret = ChangeFilePosition(_handle->handle, offset, + translatedWhence)) == 1) # else if ((ret = Seek(_handle->handle, offset, translatedWhence)) == 1) # endif @throw [OFSeekFailedException exceptionWithStream: self offset: offset Index: src/OFFileManager.m ================================================================== --- src/OFFileManager.m +++ src/OFFileManager.m @@ -56,10 +56,11 @@ # include # include #endif #ifdef OF_AMIGAOS +# define __USE_INLINE__ # include # include # include #endif Index: src/OFLocale.m ================================================================== --- src/OFLocale.m +++ src/OFLocale.m @@ -28,45 +28,18 @@ #import "OFInvalidArgumentException.h" #import "OFInvalidEncodingException.h" #import "OFOpenItemFailedException.h" #ifdef OF_AMIGAOS -# ifdef OF_AMIGAOS4 -# define __NOLIBBASE__ -# define __NOGLOBALIFACE__ -# define __USE_INLINE__ -# endif +# define __USE_INLINE__ # include # include # include #endif static OFLocale *currentLocale = nil; -#ifdef OF_AMIGAOS4 -extern struct ExecIFace *IExec; -static struct Library *DOSBase = NULL; -static struct DOSIFace *IDOS = NULL; -static struct Library *LocaleBase = NULL; -static struct LocaleIFace *ILocale = NULL; - -OF_DESTRUCTOR() -{ - if (ILocale != NULL) - DropInterface(ILocale); - - if (LocaleBase != NULL) - CloseLibrary(LocaleBase); - - if (IDOS != NULL) - DropInterface(IDOS); - - if (DOSBase != NULL) - CloseLibrary(DOSBase); -} -#endif - #ifndef OF_AMIGAOS static void parseLocale(char *locale, of_string_encoding_t *encoding, OFString **language, OFString **territory) { Index: src/OFStdIOStream.h ================================================================== --- src/OFStdIOStream.h +++ src/OFStdIOStream.h @@ -17,11 +17,11 @@ #import "OFStream.h" #import "OFKernelEventObserver.h" #ifdef OF_AMIGAOS -# include +# include #endif OF_ASSUME_NONNULL_BEGIN /*! Index: src/OFStdIOStream.m ================================================================== --- src/OFStdIOStream.m +++ src/OFStdIOStream.m @@ -40,11 +40,13 @@ #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFWriteFailedException.h" #ifdef OF_AMIGAOS +# define __USE_INLINE__ # include +# include #endif /* References for static linking */ #ifdef OF_WINDOWS void Index: src/OFThread.m ================================================================== --- src/OFThread.m +++ src/OFThread.m @@ -31,10 +31,11 @@ #include "unistd_wrapper.h" #include "platform.h" #ifdef OF_AMIGAOS +# define __USE_INLINE__ # include #endif #ifdef OF_WII # define nanosleep ogc_nanosleep Index: src/OFURLHandler_file.m ================================================================== --- src/OFURLHandler_file.m +++ src/OFURLHandler_file.m @@ -65,12 +65,16 @@ # include # include #endif #ifdef OF_AMIGAOS +# define __USE_INLINE__ # include # include +# ifdef OF_AMIGAOS4 +# define DeleteFile(path) Delete(path) +# endif #endif #if defined(OF_WINDOWS) typedef struct __stat64 of_stat_t; #elif defined(OF_AMIGAOS) @@ -105,13 +109,18 @@ { #if defined(OF_WINDOWS) return _wstat64([path UTF16String], buffer); #elif defined(OF_AMIGAOS) BPTR lock; +# ifdef OF_AMIGAOS4 + struct ExamineData *ed; +# else struct FileInfoBlock fib; +# endif of_time_interval_t timeInterval; struct Locale *locale; + struct DateStamp *date; if ((lock = Lock([path cStringWithEncoding: [OFLocale encoding]], SHARED_LOCK)) == 0) { switch (IoErr()) { case ERROR_OBJECT_IN_USE: @@ -127,12 +136,14 @@ } return -1; } -# ifdef OF_MORPHOS +# if defined(OF_MORPHOS) if (!Examine64(lock, &fib, TAG_DONE)) { +# elif defined(OF_AMIGAOS4) + if ((ed = ExamineObjectTags(EX_FileLockInput, lock, TAG_END)) == NULL) { # else if (!Examine(lock, &fib)) { # endif UnLock(lock); @@ -140,16 +151,22 @@ return -1; } UnLock(lock); -# ifdef OF_MORPHOS +# if defined(OF_MORPHOS) buffer->st_size = fib.fib_Size64; +# elif defined(OF_AMIGAOS4) + buffer->st_size = ed->FileSize; # else buffer->st_size = fib.fib_Size; # endif +# ifdef OF_AMIGAOS4 + buffer->st_mode = (EXD_IS_DIRECTORY(ed) ? S_IFDIR : S_IFREG); +# else buffer->st_mode = (fib.fib_DirEntryType > 0 ? S_IFDIR : S_IFREG); +# endif timeInterval = 252460800; /* 1978-01-01 */ locale = OpenLocale(NULL); /* @@ -158,16 +175,24 @@ * modified. */ timeInterval += locale->loc_GMTOffset * 60.0; CloseLocale(locale); - timeInterval += fib.fib_Date.ds_Days * 86400.0; - timeInterval += fib.fib_Date.ds_Minute * 60.0; - timeInterval += - fib.fib_Date.ds_Tick / (of_time_interval_t)TICKS_PER_SECOND; +# ifdef OF_AMIGAOS4 + date = &ed->Date; +# else + date = &fib.fib_Date; +# endif + timeInterval += date->ds_Days * 86400.0; + timeInterval += date->ds_Minute * 60.0; + timeInterval += date->ds_Tick / (of_time_interval_t)TICKS_PER_SECOND; buffer->st_atime = buffer->st_mtime = buffer->st_ctime = timeInterval; + +# ifdef OF_AMIGAOS4 + FreeDosObject(DOS_EXAMINEDATA, ed); +# endif return 0; #elif defined(OF_HAVE_OFF64_T) return stat64([path cStringWithEncoding: [OFLocale encoding]], buffer); #else @@ -765,11 +790,10 @@ FindClose(handle); } #elif defined(OF_AMIGAOS) of_string_encoding_t encoding = [OFLocale encoding]; BPTR lock; - struct FileInfoBlock fib; if ((lock = Lock([path cStringWithEncoding: encoding], SHARED_LOCK)) == 0) { int errNo; @@ -790,28 +814,58 @@ mode: nil errNo: errNo]; } @try { +# ifdef OF_AMIGAOS4 + struct ExamineData *ed; + APTR context; + + if ((context = ObtainDirContextTags(EX_FileLockInput, lock, + EX_DoCurrentDir, TRUE, EX_DataFields, EXF_NAME, + TAG_END)) == NULL) + @throw [OFOpenItemFailedException + exceptionWithURL: URL + mode: nil + errNo: 0]; + + @try { + while ((ed = ExamineDir(context)) != NULL) { + OFString *file = [[OFString alloc] + initWithCString: ed->Name + encoding: encoding]; + + @try { + [files addObject: file]; + } @finally { + [file release]; + } + } + } @finally { + ReleaseDirContext(context); + } +# else + struct FileInfoBlock fib; + if (!Examine(lock, &fib)) @throw [OFOpenItemFailedException exceptionWithURL: URL mode: nil errNo: 0]; while (ExNext(lock, &fib)) { - OFString *file; - - file = [[OFString alloc] + OFString *file = [[OFString alloc] initWithCString: fib.fib_FileName encoding: encoding]; + @try { [files addObject: file]; } @finally { [file release]; } } +# endif if (IoErr() != ERROR_NO_MORE_ENTRIES) @throw [OFReadFailedException exceptionWithObject: self requestedLength: 0