Created
January 25, 2012 16:09
-
-
Save mattwildig/1676982 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. */ | |
/* this check means we don't need to use StringValue */ | |
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); | |
/* these lines replace rb_str2cstr */ | |
value = RSTRING(body)->ptr; | |
newfile->size = RSRING(body)->len; | |
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