]>
git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_keychain/libDER/libDERUtils/fileIo.c
2 * Copyright (c) 2005-2007,2010-2012 Apple Inc. All Rights Reserved.
10 #include <sys/types.h>
16 const unsigned char *bytes
,
22 fd
= open(fileName
, O_RDWR
| O_CREAT
| O_TRUNC
, 0600);
26 rtn
= (int)write(fd
, bytes
, (size_t)numBytes
);
27 if(rtn
!= (int)numBytes
) {
29 fprintf(stderr
, "writeFile: short write\n");
45 unsigned char **bytes
, // mallocd and returned
46 unsigned *numBytes
) // returned
56 fd
= open(fileName
, O_RDONLY
, 0);
64 size
= (unsigned) sb
.st_size
;
65 buf
= (char *)malloc(size
);
70 rtn
= (int)read(fd
, buf
, size
);
73 fprintf(stderr
, "readFile: short read\n");
79 *bytes
= (unsigned char *)buf
;