Programmer's Reference

Closing file descriptors

Once all desired operations have been performed on a file descriptor, it must be closed before being discarded. This is accomplished by sending the file descriptor the close message, which deallocates all operating system resources associated with it.

| fd |
(fd := CfsFileDescriptor
    open: 'example.txt'
    oflag: ORDWR | OCREAT | OTRUNC) isCfsError
        ifTrue: [^self error: fd message].
 
"... Put file operations here ..."
fd close.
"Close file when done"


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]