Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ehowe
Created January 25, 2012 13:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ehowe/1676278 to your computer and use it in GitHub Desktop.
Save ehowe/1676278 to your computer and use it in GitHub Desktop.
if (RTEST(rf_call(path,is_file,Qnil))) {
body = rf_call(path, id_read_file,Qnil);
/* I don't wanna deal with non-strings :D. */
if (TYPE(body) != T_STRING) {
return -ENOENT;
}
/* We have the body, now save it the entire contents to our
* opened_file lists. */
newfile = ALLOC(opened_file);
value = rb_str2cstr(body,&newfile->size);
newfile->value = ALLOC_N(char,(newfile->size)+1);
memcpy(newfile->value,value,newfile->size);
newfile->writesize = newfile->size+1;
newfile->path = strdup(path);
newfile->raw = 0;
newfile->zero_offset = 0;
} else
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment