~ chicken-core (master) /manual/Module (scheme file)
Trap1[[tags: manual]]2[[toc:]]34== Module (scheme file)56<procedure>(call-with-input-file string proc)</procedure><br>7<procedure>(call-with-output-file string proc)</procedure>89It is an error if proc does not accept one argument.1011These procedures obtain a textual port obtained by opening the named file for12input or output as if by open-input-file or open-output-file. The port and13proc are then passed to a procedure equivalent to call-with-port.1415<procedure>(with-input-from-file string thunk)</procedure><br>16<procedure>(with-output-to-file string thunk)</procedure><br>1718The file is opened for input or output as if by open-input-file or19open-output-file, and the new port is made to be the value returned by20current-input-port or current-output-port (as used by {{(read)}}, {{(write obj)}}, and so forth). The21thunk is then called with no arguments. When the22thunk returns, the port is closed and the previous default is restored. It is23an error if24thunk does not accept zero arguments. Both procedures return the values yielded25by26thunk. If an escape procedure is used to escape from the continuation of these27procedures, they behave exactly as if the current input or output port had been28bound dynamically with parameterize.2930<procedure>(open-input-file string)</procedure><br>31<procedure>(open-binary-input-file string)</procedure><br>3233Takes a34string for an existing file and returns a textual input port or binary input35port that is capable of delivering data from the file. If the file does not36exist or cannot be opened, an error that satisfies file-error? is signaled.3738<procedure>(open-output-file string)</procedure><br>39<procedure>(open-binary-output-file string)</procedure><br>4041Takes a42string naming an output file to be created and returns a textual output port or43binary output port that is capable of writing data to a new file by that name.44If a file with the given name already exists, the effect is unspecified. If the45file cannot be opened, an error that satisfies file-error? is signaled.4647<procedure>(file-exists? filename)</procedure><br>4849It is an error if50filename is not a string.5152The file-exists? procedure returns #t if the named file exists at the time the53procedure is called, and #f otherwise.5455<procedure>(delete-file filename)</procedure><br>5657It is an error if58filename is not a string.5960The delete-file procedure deletes the named file if it exists and can be61deleted, and returns an unspecified value. If the file does not exist or cannot62be deleted, an error that satisfies file-error? is signaled.6364---65Previous: [[Module (scheme complex)]]6667Next: [[Module (scheme eval)]]