OSFileHandle.st
author Jan Vrany <jan.vrany@labware.com>
Tue, 01 Jun 2021 20:19:13 +0100
branchjv
changeset 25424 51bd8a6b196f
parent 18120 e3a375d5f6a8
permissions -rw-r--r--
Cherry-picked `Context` cherry-picked Context.st from a6b6dda4caff: * 4aaf30c174e9: #DOCUMENTATION by cg, Claus Gittinger <cg@exept.de> * c67311afcc6c: #OTHER by cg, Claus Gittinger <cg@exept.de> * 883f79e7b2a6: #FEATURE by cg, Claus Gittinger <cg@exept.de> * 716f3fbb09e9: Don't mark contexts with `CATCHMARK`, Jan Vrany <jan.vrany@fit.cvut.cz> * cff24fa817b0: #REFACTORING by stefan, Stefan Vogel <sv@exept.de> * 521f0d837330: #UI_ENHANCEMENT by cg, Claus Gittinger <cg@exept.de> * bf1118f0fcca: #UI_ENHANCEMENT by cg, Claus Gittinger <cg@exept.de> * e587cdd22868: #BUGFIX by cg, Claus Gittinger <cg@exept.de> * fe9f9487a3ed: #DOCUMENTATION by cg, Claus Gittinger <cg@exept.de> * d5b781899274: #BUGFIX by cg, Claus Gittinger <cg@exept.de> * 8258751a7465: #FEATURE by cg, Claus Gittinger <cg@exept.de> * 40173e082cbc: Copyright updates, Jan Vrany <jan.vrany@fit.cvut.cz> * 6db5c28207d5: #UI_ENHANCEMENT by cg, Claus Gittinger <cg@exept.de> * 871ea64fd5dc: #FEATURE by cg, Claus Gittinger <cg@exept.de> * 4b544a108e4e: #DOCUMENTATION by cg, Claus Gittinger <cg@exept.de> * 9a8d8399e566: #FEATURE by cgexept.de, Claus Gittinger <cg@exept.de> * 170b00be0103: #BUGFIX by stefan, Stefan Vogel <sv@exept.de> * a6c73965eae8: #FEATURE by cg, Claus Gittinger <cg@exept.de> * ce2a0e462ff0: #FEATURE by cg, Claus Gittinger <cg@exept.de> * 46a260a9ca92: #FEATURE by cg, Claus Gittinger <cg@exept.de> * 46cab49167fb: #UI_ENHANCEMENT by exept, Claus Gittinger <cg@exept.de> * 7d52dfd3997d: #DOCUMENTATION by exept, Claus Gittinger <cg@exept.de> * c52eeea62763: Fix `Context >> argAndVarNames` in cases when debug info is not available, Jan Vrany <jan.vrany@labware.com> * b5d6963fe4a9: Backed out changeset c52eeea62763, Jan Vrany <jan.vrany@labware.com> * 6fd3896f8703: #FEATURE by exept, Claus Gittinger <cg@exept.de> * b530ee616256: #REFACTORING by cg, Claus Gittinger <cg@exept.de> * ef9b481d7498: #FEATURE by cg, Claus Gittinger <cg@exept.de> * ea663b72bd51: #UI_ENHANCEMENT by cg, Claus Gittinger <cg@exept.de> * 6179572a733c: #FEATURE by exept, Claus Gittinger <cg@exept.de> * 84155b1b6622: #DOCUMENTATION by exept, Claus Gittinger <cg@exept.de> * 37d06602d856: *** empty log message ***, Claus Gittinger <cg@exept.de> * f927b9022fea: *** empty log message ***, Claus Gittinger <cg@exept.de> * 427d3be62d97: #UI_ENHANCEMENT by exept, Claus Gittinger <cg@exept.de>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7593
e7550b9ef84a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6439
diff changeset
     1
"
e7550b9ef84a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6439
diff changeset
     2
 COPYRIGHT (c) 1999 by eXept Software AG
e7550b9ef84a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6439
diff changeset
     3
              All Rights Reserved
e7550b9ef84a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6439
diff changeset
     4
e7550b9ef84a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6439
diff changeset
     5
 This software is furnished under a license and may be used
e7550b9ef84a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6439
diff changeset
     6
 only in accordance with the terms of that license and with the
e7550b9ef84a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6439
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
e7550b9ef84a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6439
diff changeset
     8
 be provided or otherwise made available to, or used by, any
e7550b9ef84a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6439
diff changeset
     9
 other person.  No title to or ownership of the software is
e7550b9ef84a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6439
diff changeset
    10
 hereby transferred.
e7550b9ef84a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6439
diff changeset
    11
"
5409
9b5890348f9c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4763
diff changeset
    12
"{ Package: 'stx:libbasic' }"
9b5890348f9c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4763
diff changeset
    13
4763
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
OSHandle subclass:#OSFileHandle
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
	instanceVariableNames:''
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	classVariableNames:'ConcreteClass'
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	poolDictionaries:''
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	category:'System-Support'
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
7593
e7550b9ef84a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6439
diff changeset
    21
!OSFileHandle class methodsFor:'documentation'!
e7550b9ef84a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6439
diff changeset
    22
e7550b9ef84a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6439
diff changeset
    23
copyright
e7550b9ef84a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6439
diff changeset
    24
"
e7550b9ef84a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6439
diff changeset
    25
 COPYRIGHT (c) 1999 by eXept Software AG
e7550b9ef84a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6439
diff changeset
    26
              All Rights Reserved
e7550b9ef84a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6439
diff changeset
    27
e7550b9ef84a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6439
diff changeset
    28
 This software is furnished under a license and may be used
e7550b9ef84a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6439
diff changeset
    29
 only in accordance with the terms of that license and with the
e7550b9ef84a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6439
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
e7550b9ef84a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6439
diff changeset
    31
 be provided or otherwise made available to, or used by, any
e7550b9ef84a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6439
diff changeset
    32
 other person.  No title to or ownership of the software is
e7550b9ef84a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6439
diff changeset
    33
 hereby transferred.
e7550b9ef84a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6439
diff changeset
    34
"
e7550b9ef84a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6439
diff changeset
    35
! !
4763
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
!OSFileHandle class methodsFor:'initialization'!
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
initialize
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
    "initialize for the OS we are running on"
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
    self initializeConcreteClass
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
    "
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
     self initialize
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
    "
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
!
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
initializeConcreteClass
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
    "initialize for the OS we are running on"
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
    OperatingSystem isMSDOSlike ifTrue:[
6289
82cf5f13d5d7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
    55
        ConcreteClass := Win32FILEHandle
4763
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
    ] ifFalse:[
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
        OperatingSystem isVMSlike ifTrue:[
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
            ConcreteClass := OpenVMSFileHandle
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
        ] ifFalse:[
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
            OperatingSystem isUNIXlike ifTrue:[
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
                ConcreteClass := UnixFileHandle
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
            ] ifFalse:[
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
                ConcreteClass := nil
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
            ]
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
        ]
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
    ]
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
    "
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
     self initializeConcreteClass
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
    "
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
    "Modified: 7.9.1997 / 23:32:37 / cg"
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
!
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
reinitialize
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
    "initialize for the OS we are running on"
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
    self initializeConcreteClass
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
    "
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
     self reinitialize
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
    "
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
! !
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
!OSFileHandle methodsFor:'finalization'!
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
6439
0f841258ec4a Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents: 6289
diff changeset
    90
finalize
5409
9b5890348f9c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4763
diff changeset
    91
    "a filedescriptor was garbage collected - close the underlying file"
4763
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
16549
f390a82315e7 class: OSFileHandle
Claus Gittinger <cg@exept.de>
parents: 9101
diff changeset
    93
    "/ with timeout to avoid blocking in a bad pty/socket
f390a82315e7 class: OSFileHandle
Claus Gittinger <cg@exept.de>
parents: 9101
diff changeset
    94
    [
f390a82315e7 class: OSFileHandle
Claus Gittinger <cg@exept.de>
parents: 9101
diff changeset
    95
        self closeFile
f390a82315e7 class: OSFileHandle
Claus Gittinger <cg@exept.de>
parents: 9101
diff changeset
    96
    ] valueWithTimeout:30 seconds
5409
9b5890348f9c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4763
diff changeset
    97
! !
9b5890348f9c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4763
diff changeset
    98
5413
4e67713bf25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5409
diff changeset
    99
!OSFileHandle methodsFor:'input/output'!
4e67713bf25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5409
diff changeset
   100
4e67713bf25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5409
diff changeset
   101
readBytes:count into:aByteBuffer startingAt:startAddress
4e67713bf25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5409
diff changeset
   102
    "read count bytes into a byte-buffer;
4e67713bf25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5409
diff changeset
   103
     Return the number of bytes read (negative on error)"
4e67713bf25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5409
diff changeset
   104
4e67713bf25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5409
diff changeset
   105
    ^ self subclassResponsibility
4e67713bf25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5409
diff changeset
   106
4e67713bf25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5409
diff changeset
   107
!
4e67713bf25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5409
diff changeset
   108
4e67713bf25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5409
diff changeset
   109
writeBytes:count from:aByteBuffer startingAt:startAddress
4e67713bf25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5409
diff changeset
   110
    "write count bytes from a byte-buffer;
4e67713bf25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5409
diff changeset
   111
     Return the number of bytes written (negative on error)"
4e67713bf25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5409
diff changeset
   112
4e67713bf25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5409
diff changeset
   113
    ^ self subclassResponsibility
4e67713bf25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5409
diff changeset
   114
4e67713bf25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5409
diff changeset
   115
! !
4e67713bf25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5409
diff changeset
   116
5409
9b5890348f9c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4763
diff changeset
   117
!OSFileHandle methodsFor:'release'!
9b5890348f9c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4763
diff changeset
   118
9b5890348f9c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4763
diff changeset
   119
close
9b5890348f9c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4763
diff changeset
   120
    "close the file"
9b5890348f9c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4763
diff changeset
   121
9b5890348f9c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4763
diff changeset
   122
    self closeFile.
9b5890348f9c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4763
diff changeset
   123
    self unregisterForFinalization.
5413
4e67713bf25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5409
diff changeset
   124
!
4e67713bf25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5409
diff changeset
   125
4e67713bf25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5409
diff changeset
   126
closeFile
4e67713bf25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5409
diff changeset
   127
    "close the underlying file"
4e67713bf25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5409
diff changeset
   128
4e67713bf25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5409
diff changeset
   129
    self subclassResponsibility
4e67713bf25a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5409
diff changeset
   130
4763
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
! !
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
!OSFileHandle class methodsFor:'documentation'!
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
version
16549
f390a82315e7 class: OSFileHandle
Claus Gittinger <cg@exept.de>
parents: 9101
diff changeset
   136
    ^ '$Header: /cvs/stx/stx/libbasic/OSFileHandle.st,v 1.8 2014-06-07 15:08:16 cg Exp $'
4763
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
! !
7593
e7550b9ef84a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6439
diff changeset
   138
16549
f390a82315e7 class: OSFileHandle
Claus Gittinger <cg@exept.de>
parents: 9101
diff changeset
   139
4763
d15c41a66ec4 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
OSFileHandle initialize!