Site Tools


open
no way to compare when less than two revisions

Differences

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


open [2012/07/04 06:30] (current) – created - external edit 127.0.0.1
Line 1: Line 1:
 +# $EPIC: open.txt,v 1.5 2012/07/04 06:30:23 jnelson Exp $
 +======Synopsis:======
 +$__open__(%%<filename>%% R|W)
 +
 +======Technical:======
 +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.
 +
 +======Practical:======
 +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.
 +
 +======Returns:======
 +file descriptor, or -1 if error
 +
 +======Options:======
 +|     |open file for reading    |
 +|     |open file for writing    |
 +
 +======Examples:======
 +<file>
 +$open(~/.ircrc W)                 open your .ircrc for writing
 +$open(~/.irclog R)                open your logfile for reading
 +$open(/etc/passwd W)              will probably fail
 +</file>
  
open.txt · Last modified: 2012/07/04 06:30 by 127.0.0.1