View/Edit #1:filewrite

Switch to edit mode.

Name(s): filewrite
1:  {file, data} = args
2:  if (!$perm_utils:controls(caller_perms(), this))
3:    raise(E_PERM)
4:  elseif ($recycler:valid(this.owner) && this.owner:free_dbytes() <= 0 && !caller_perms().wizard)
5:    raise(E_QUOTA, "Disk quota exhasted.")
6:  elseif (file in this.files_unwritable_by_owner && !caller_perms().wizard)
7:    raise(E_PERM, "File is not writable by the owner.")
8:  endif
9:  if (this:file_exists(file))
10:   perms = this:file_access(file)
11: else
12:   perms = "r"
13: endif
14: fh = file_open($file_utils:filespec(this, file), "w-tf")
15: try
16:   for x in (data)
17:     file_writeline(fh, tostr(x))
18:     $command_utils:suspend_if_needed()
19:   endfor
20: finally
21:   file_close(fh)
22: endtry
23: this.obj_disk_size = this.obj_disk_size + this:file_size(file)
24: this:file_set_access(file, perms)
25: "Last modified by whiz (#3135) on Tue Aug 13 22:50:02 2002 MDT."

Verb arguments: this none this
Verb perms: Readable eXecutable NOT-Debug
Verb owned by: Slacker (#55)

You are not logged in.

[home | help | who | search | setup | code]