- C++相談室 part112
387 :デフォルトの名無しさん[sage]:2014/04/29(火) 18:51:14.18 ID:u8cJRNln - //as-util.h
namespace as { int open_or_die(const string& filename, int flags, int mode = 0) { int fd = open(filename.c_str(), flags, mode); if (fd == -1) { fprintf(stderr, "Could not open %s (%s)\n", filename.c_str(), strerror(errno)); exit(-1); } return fd; } int write_file(const string& filename, const void* buff, unsigned int len) { int out_fd; out_fd = open_or_die(filename, 33537, 384); write(out_fd, buff, len); return close(out_fd); } }
|