@@ -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