Index: src/OFFileIRIHandler.m ================================================================== --- src/OFFileIRIHandler.m +++ src/OFFileIRIHandler.m @@ -40,10 +40,13 @@ #endif #ifdef OF_DJGPP # include #endif +#ifdef HAVE_FCNTL_H +# include +#endif #ifdef HAVE_PWD_H # include #endif #ifdef HAVE_GRP_H # include @@ -469,31 +472,11 @@ static void setSymbolicLinkDestinationAttribute(OFMutableFileAttributes attributes, OFIRI *IRI) { OFString *path = IRI.fileSystemRepresentation; -# ifndef OF_WINDOWS - OFStringEncoding encoding = [OFLocale encoding]; - char destinationC[PATH_MAX]; - ssize_t length; - OFString *destination; - - length = readlink([path cStringWithEncoding: encoding], destinationC, - PATH_MAX); - - if (length < 0) - @throw [OFGetItemAttributesFailedException - exceptionWithIRI: IRI - errNo: errno]; - - destination = [OFString stringWithCString: destinationC - encoding: encoding - length: length]; - - [attributes setObject: destination - forKey: OFFileSymbolicLinkDestination]; -# else +# ifdef OF_WINDOWS HANDLE handle; OFString *destination; if (createSymbolicLinkWFuncPtr == NULL) return; @@ -540,10 +523,59 @@ forKey: OFFileSymbolicLinkDestination]; # undef slrb } @finally { CloseHandle(handle); } +# elif defined(OF_HURD) + OFStringEncoding encoding = [OFLocale encoding]; + int fd; + OFMutableData *destinationData; + OFString *destination; + + fd = open([path cStringWithEncoding: encoding], O_RDONLY | O_NOLINK); + if (fd == -1) + @throw [OFGetItemAttributesFailedException + exceptionWithIRI: IRI + errNo: errno]; + + @try { + char buffer[512]; + ssize_t length; + + destinationData = [OFMutableData data]; + while ((length = read(fd, buffer, 512)) > 0) + [destinationData addItems: buffer count: length]; + } @finally { + close(fd); + } + + destination = [OFString stringWithCString: destinationData.items + encoding: encoding + length: destinationData.count]; + + [attributes setObject: destination + forKey: OFFileSymbolicLinkDestination]; +# else + OFStringEncoding encoding = [OFLocale encoding]; + char destinationC[PATH_MAX]; + ssize_t length; + OFString *destination; + + length = readlink([path cStringWithEncoding: encoding], destinationC, + PATH_MAX); + + if (length < 0) + @throw [OFGetItemAttributesFailedException + exceptionWithIRI: IRI + errNo: errno]; + + destination = [OFString stringWithCString: destinationC + encoding: encoding + length: length]; + + [attributes setObject: destination + forKey: OFFileSymbolicLinkDestination]; # endif } #endif #ifdef OF_FILE_MANAGER_SUPPORTS_EXTENDED_ATTRIBUTES Index: src/OFFileManager.m ================================================================== --- src/OFFileManager.m +++ src/OFFileManager.m @@ -171,10 +171,26 @@ return nil; } return [OFString stringWithCString: buffer encoding: [OFLocale encoding]]; +# elif defined(OF_GLIBC) + char *buffer; + OFString *path; + + if ((buffer = getcwd(NULL, 0)) == NULL) + @throw [OFGetCurrentDirectoryFailedException + exceptionWithErrNo: errno]; + + @try { + path = [OFString stringWithCString: buffer + encoding: [OFLocale encoding]]; + } @finally { + free(buffer); + } + + return path; # else char buffer[PATH_MAX]; if ((getcwd(buffer, PATH_MAX)) == NULL) @throw [OFGetCurrentDirectoryFailedException Index: src/platform.h ================================================================== --- src/platform.h +++ src/platform.h @@ -152,10 +152,14 @@ #elif defined(__MINT__) # define OF_MINT #elif defined(__gnu_hurd__) # define OF_HURD #endif + +#ifdef __GLIBC__ +# define OF_GLIBC +#endif #if defined(__ELF__) # define OF_ELF #elif defined(__MACH__) # define OF_MACH_O