Skip to content

Instantly share code, notes, and snippets.

@jaytaph
Created March 16, 2015 19:19
Show Gist options
  • Save jaytaph/b95fbf21c571209992d3 to your computer and use it in GitHub Desktop.
Save jaytaph/b95fbf21c571209992d3 to your computer and use it in GitHub Desktop.
SAFFIRE_MODULE_METHOD(file, write) {
t_file_object *file_obj = (t_file_object *)self;
t_string_object *str_obj;
if (! object_parse_arguments(SAFFIRE_METHOD_ARGS, "s", &str_obj)) {
return NULL;
}
long bytes_written = fwrite(str_obj->data.value->val, 1, str_obj->data.value->len, file_obj->data.fp);
file_obj->data.bytes_out += bytes_written;
RETURN_NUMERICAL(bytes_written);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment