]>
git.saurik.com Git - apple/security.git/blob - libsecurity_keychain/libDER/libDERUtils/fileIo.c
2 * Copyright (c) 2005-2007,2010 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
= 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
= (size_t) sb
.st_size
;
65 buf
= (char *)malloc(size
);
70 rtn
= read(fd
, buf
, (size_t)size
);
71 if(rtn
!= (int)size
) {
73 fprintf(stderr
, "readFile: short read\n");
79 *bytes
= (unsigned char *)buf
;