value ImageCreateFromGif(value filename) { FILE *_file = openFileRead(filename); gdImagePtr img = gdImageCreateFromGif(_file); fclose(_file); if (img == NULL) failure("image file could not be loaded: probably wrong format"); return alloc_gc_image(img); }
value ImageCreateFromGd2Part(value filename, value srcX, value srcY, value width, value height) { FILE *_file = openFileRead(filename); int _srcX = val_int(srcX); int _srcY = val_int(srcY); int _width = val_int(width); int _height = val_int(height); gdImagePtr img = gdImageCreateFromGd2Part(_file,_srcX,_srcY,_width,_height); fclose(_file); return alloc_gc_image(img); }
std::string FileSystem::readFileAsString(const std::string &fileName) { std::stringstream result; if(exists(fileName)) { auto fs = openFileRead(fileName); result << fs->rdbuf(); } return result.str(); }
std::vector<char> FileSystem::readFileAsCharBuffer(const std::string & fileName) { std::vector<char> buffer; if(exists(fileName)) { int length = 0; auto fs = openFileRead(fileName); fs->seekg (0, std::ios::end); length = static_cast<int>(fs->tellg()); fs->seekg (0, std::ios::beg); buffer.reserve(length); fs->read(&buffer[0], length); } return buffer; }
int openStudentFile(FILE **fileRead, FILE **fileWrite) { if (openFileRead("data.txt", fileRead) == -1) { // if open file has error, then create the file if (openFileWrite("data.txt", fileWrite) == -1) { printf("Cannot create data.txt! Serious error! \n"); return -1; } else { printf("Created empty data.txt, because file did not exist\n"); fprintf(*fileWrite, "%s\t%s\t%s\t%s\t\n", "회원ID", "회원이름", "회원주소", "핸드폰번호"); fflush(*fileWrite); return 1; } } return 0; }
value ImageCreateFromWBMP(value filename) { FILE *_file = openFileRead(filename); gdImagePtr img = gdImageCreateFromWBMP(_file); fclose(_file); return alloc_gc_image(img); }