User Tools

Site Tools



This shows you the differences between two versions of the page.

Link to this comparison view

open [2012/07/04 06:30] (current)
Line 1: Line 1:
 +# $EPIC: open.txt,v 1.5 2012/07/04 06:30:23 jnelson Exp $
 +$__open__(%%<​filename>​%% R|W)
 +Important: The %%<​filename>​%% can be surrounded by double quotes, which is 
 +different from most functions. ​ You can use tilde-expansion for homedirs.
 +This opens a file for reading from the beginning, or writing to the end.
 +The return value is a file descriptor you can pass to [[read]] or [[write]]
 +and eventually [[close]].
 +This functions allows the client to open an arbitrary file for reading or
 +writing. ​ Write mode appends to the file.  The function returns a file
 +descriptor for the open file; the file descriptor is an integer. ​ Tilde-
 +expansion is permitted.
 +The $__open__() function is the doorway to external file access from
 +within the client (aside from [[exec command|EXEC]]ing a process).
 +Assuming the file has the appropriate permissions,​ it allows you to open
 +the file for read or write access (but not both). ​ Write access only
 +appends to the file, so you'll need to use $[[unlink]]() or
 +$[[rename]]() if you want to start fresh.
 +file descriptor, or -1 if error
 +|   ​R ​  |open file for reading ​   |
 +|   ​W ​  |open file for writing ​   |
 +$open(~/​.ircrc W)                 open your .ircrc for writing
 +$open(~/​.irclog R)                open your logfile for reading
 +$open(/​etc/​passwd W)              will probably fail
open.txt ยท Last modified: 2012/07/04 06:30 (external edit)