Mercurial > hg > Members > kono > os9 > sbc09
comparison src/vdisk.c @ 148:fa0fbcbccbc9
add easy fmemopen replacement
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 17 Jan 2019 07:43:13 +0900 |
parents | eb9be32c701c |
children | 2f71506f980f |
comparison
equal
deleted
inserted
replaced
147:9d7faeeea618 | 148:fa0fbcbccbc9 |
---|---|
254 if ((m&0x10)) mode|=S_IWOTH ; | 254 if ((m&0x10)) mode|=S_IWOTH ; |
255 if ((m&0x20)) mode|=S_IXOTH ; | 255 if ((m&0x20)) mode|=S_IXOTH ; |
256 return mode; | 256 return mode; |
257 } | 257 } |
258 | 258 |
259 #ifndef fmemopen | |
260 | |
261 FILE *fmemopen(char *buf,long sz, const char *mode) { | |
262 static char fname[] = "/tmp/myfileXXXXXX"; | |
263 int fd; | |
264 fd = mkstemp(fname); /* Create and open temp file */ | |
265 write(fd, buf, sz); /* Write something to file */ | |
266 lseek(fd, 0L, SEEK_SET); | |
267 FILE *fp = fdopen(fd,mode); | |
268 unlink(fname); | |
269 return fp; | |
270 } | |
271 | |
272 #endif | |
259 | 273 |
260 /* | 274 /* |
261 * os9 file descriptor | 275 * os9 file descriptor |
262 * * File Descriptor Format | 276 * * File Descriptor Format |
263 * | 277 * |