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