]>
git.saurik.com Git - apple/security.git/blob - Security/utilities/src/fileIo.c
2 * Copyright (c) 2005-2007,2010,2012-2013 Apple Inc. All Rights Reserved.
10 #include <sys/types.h>
17 const unsigned char *bytes
,
25 fwrite(bytes
, 1, numBytes
, stdout
);
27 return ferror(stdout
);
30 fd
= open(fileName
, O_RDWR
| O_CREAT
| O_TRUNC
, 0600);
34 wrc
= write(fd
, bytes
, (size_t)numBytes
);
37 fprintf(stderr
, "writeFile: short write\n");
53 unsigned char **bytes
, // mallocd and returned
54 size_t *numBytes
) // returned
65 fd
= open(fileName
, O_RDONLY
);
73 if (sb
.st_size
> SIZE_MAX
) {
77 size
= (size_t)sb
.st_size
;
78 buf
= (char *)malloc(size
);
83 rrc
= read(fd
, buf
, size
);
87 fprintf(stderr
, "readFile: short read\n");
93 *bytes
= (unsigned char *)buf
;