@@ -40,10 +40,11 @@ #import "OFURLHandler.h" #import "OFChangeCurrentDirectoryPathFailedException.h" #import "OFCopyItemFailedException.h" #import "OFGetCurrentDirectoryPathFailedException.h" +#import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFMoveItemFailedException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "OFRemoveItemFailedException.h" @@ -56,18 +57,28 @@ # include # include #endif #ifdef OF_AMIGAOS -# define __USE_INLINE__ +# ifdef OF_AMIGAOS4 +# define __USE_INLINE__ +# define __NOLIBBASE__ +# define __NOGLOBALIFACE__ +# endif # include # include # include #endif @interface OFFileManager_default: OFFileManager @end + +#ifdef OF_AMIGAOS4 +extern struct ExecIFace *IExec; +static struct Library *DOSBase = NULL; +static struct DOSIFace *IDOS = NULL; +#endif static OFFileManager *defaultManager; const of_file_attribute_key_t of_file_attribute_key_size = @"of_file_attribute_key_size"; @@ -107,10 +118,18 @@ OF_DESTRUCTOR() { if (dirChanged) UnLock(CurrentDir(originalDirLock)); + +# ifdef OF_AMIGAOS4 + if (IDOS != NULL) + DropInterface(IDOS); + + if (DOSBase != NULL) + CloseLibrary(DOSBase); +# endif } #endif static id attributeForKeyOrException(of_file_attributes_t attributes, @@ -128,10 +147,21 @@ @implementation OFFileManager + (void)initialize { if (self != [OFFileManager class]) return; + +#ifdef OF_AMIGAOS4 + if ((DOSBase = OpenLibrary("dos.library", 36)) == NULL) + @throw [OFInitializationFailedException + exceptionWithClass: self]; + + if ((IDOS = (struct DOSIFace *) + GetInterface(DOSBase, "main", 1, NULL)) == NULL) + @throw [OFInitializationFailedException + exceptionWithClass: self]; +#endif defaultManager = [[OFFileManager_default alloc] init]; } + (OFFileManager *)defaultManager