diff -r 9b6be9f46f15 -r 7ec3bfc7f070 UnixOperatingSystem.st --- a/UnixOperatingSystem.st Fri Apr 17 09:46:35 2020 +0200 +++ b/UnixOperatingSystem.st Mon Apr 20 13:57:16 2020 +0200 @@ -1,5 +1,3 @@ -"{ Encoding: utf8 }" - " COPYRIGHT (c) 1988 by Claus Gittinger All Rights Reserved @@ -1955,41 +1953,41 @@ if ((dirPointer != nil) && __isExternalAddressLike(dirPointer)) { - d = (DIR *)__FILEVal(dirPointer); - - __BEGIN_INTERRUPTABLE__ - do { - do { - __threadErrno = 0; - dp = readdir(d); - /* - * for compatibility with ST-80, - * skip entries for '.' and '..'. - * If wanted, these must be added synthetically. - */ - } while (dp && ((strcmp(dp->d_name, ".")==0) || (strcmp(dp->d_name, "..")==0))); - } while ((dp == NULL) && (__threadErrno == EINTR)); - __END_INTERRUPTABLE__ - - if (dp != NULL) { - entry = __MKSTRING((char *)(dp->d_name)); - } else { - if (__threadErrno) { - error = __mkSmallInteger(__threadErrno); - } + d = (DIR *)__FILEVal(dirPointer); + + __BEGIN_INTERRUPTABLE__ + do { + do { + __threadErrno = 0; + dp = readdir(d); + /* + * for compatibility with ST-80, + * skip entries for '.' and '..'. + * If wanted, these must be added synthetically. + */ + } while (dp && ((strcmp(dp->d_name, ".")==0) || (strcmp(dp->d_name, "..")==0))); + } while ((dp == NULL) && (__threadErrno == EINTR)); + __END_INTERRUPTABLE__ + + if (dp != NULL) { + entry = __MKSTRING((char *)(dp->d_name)); + } else { + if (__threadErrno) { + error = __mkSmallInteger(__threadErrno); + } } } #endif /* HAS_OPENDIR */ %}. error notNil ifTrue:[ - ^ StreamIOError newException - errorCode:error; - osErrorHolder:(OperatingSystem errorHolderForNumber:error); - parameter:aDirectoryStream; - raiseRequest + ^ StreamIOError newException + errorCode:error; + osErrorHolder:(self errorHolderForNumber:error); + parameter:aDirectoryStream; + raiseRequest ]. entry notNil ifTrue:[ - ^ FileStatusInfo new sourcePath:(self decodePath:entry). + ^ FileStatusInfo new sourcePath:(self decodePath:entry). ]. ^ aDirectoryStream pastEndRead ! ! @@ -3804,8 +3802,11 @@ ! copyFromFd:inFd toFd:outFd startIndex:startIdx count:count - "directly copy from one Fd to another (if supported by the OS)" - + "directly copy data from inFd to outFd (if supported by the OS). + Start the copy at the 0-based index startIdx of inFd and copy count bytes. + Answer the number of bytes copied." + + |error| %{ #if defined(HAS_SENDFILE) # include @@ -3817,27 +3818,43 @@ off_t startOffset = __intVal(startIdx); ssize_t __count = __intVal(count); ssize_t totalCount = 0; - + // sendfile may copy partial data, so do it in a loop. // caller has to check that all data has been written and take measure if not. do { ssize_t writeCount = sendfile(__intVal(outFd), __intVal(inFd), &startOffset, __count); if (writeCount < 0) { - @global(LastErrorNumber) = __mkSmallInteger(errno); - __count = 0; + error = __mkSmallInteger(errno); + __count = -1; } else { totalCount += writeCount; startOffset += writeCount; // in case we have to loop __count -= writeCount; } - } while (__count > 0); - RETURN (__mkSmallInteger(totalCount)); + } while (__count > 0); + if (__count >= 0) { + RETURN (__mkSmallInteger(totalCount)); + } } #endif %}. + + error notNil ifTrue:[ + LastErrorNumber := error. + ^ WriteError newException + errorCode:error; + osErrorHolder:(self errorHolderForNumber:error); + parameter:outFd; + raiseRequest + ]. ^ 0 "/ not supported - "Modified: / 15-04-2020 / 16:36:03 / Stefan Vogel" + " + This should fail: + self copyFromFd:500 toFd:200 startIndex:1 count:20 + " + + "Modified (comment): / 20-04-2020 / 11:41:51 / Stefan Vogel" ! createDirectory:aPathName @@ -9813,7 +9830,7 @@ Codeset := #'utf8-mac'. CodesetEncoder := nil. OperatingSystem getCodesetEncoder - OperatingSystem encodePath:'äöü' + OperatingSystem encodePath:'äöü' " "Modified: / 23-01-2013 / 10:00:11 / Jan Vrany " @@ -13676,9 +13693,9 @@ domain:#'AF_UNSPEC' type:nil protocol:nil flags:nil self getAddressInfo:'www.exept.de' serviceName:nil domain:#'AF_INET6' type:nil protocol:nil flags:nil - self getAddressInfo:'www.baden-württemberg.de' serviceName:nil + self getAddressInfo:'www.baden-württemberg.de' serviceName:nil domain:#'AF_INET' type:#stream protocol:nil flags:nil - self getAddressInfo:'www.baden-württemberg.de' serviceName:nil + self getAddressInfo:'www.baden-württemberg.de' serviceName:nil domain:#'AF_INET6' type:#stream protocol:nil flags:nil "