X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/dd5fb164cf5b32c462296bc65e289e100f74b59a..8a50f688fe9358387648fb83fbfecbefe8d32669:/OSX/libsecurity_keychain/libDER/libDERUtils/fileIo.c?ds=inline diff --git a/OSX/libsecurity_keychain/libDER/libDERUtils/fileIo.c b/OSX/libsecurity_keychain/libDER/libDERUtils/fileIo.c deleted file mode 100644 index a050fe5a..00000000 --- a/OSX/libsecurity_keychain/libDER/libDERUtils/fileIo.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2005-2007,2010-2012 Apple Inc. All Rights Reserved. - */ - -#include -#include -#include -#include -#include -#include -#include -#include "fileIo.h" - -int writeFile( - const char *fileName, - const unsigned char *bytes, - unsigned numBytes) -{ - int rtn; - int fd; - - fd = open(fileName, O_RDWR | O_CREAT | O_TRUNC, 0600); - if(fd == -1) { - return errno; - } - rtn = (int)write(fd, bytes, (size_t)numBytes); - if(rtn != (int)numBytes) { - if(rtn >= 0) { - fprintf(stderr, "writeFile: short write\n"); - } - rtn = EIO; - } - else { - rtn = 0; - } - close(fd); - return rtn; -} - -/* - * Read entire file. - */ -int readFile( - const char *fileName, - unsigned char **bytes, // mallocd and returned - unsigned *numBytes) // returned -{ - int rtn; - int fd; - char *buf; - struct stat sb; - unsigned size; - - *numBytes = 0; - *bytes = NULL; - fd = open(fileName, O_RDONLY, 0); - if(fd == -1) { - return errno; - } - rtn = fstat(fd, &sb); - if(rtn) { - goto errOut; - } - size = (unsigned) sb.st_size; - buf = (char *)malloc(size); - if(buf == NULL) { - rtn = ENOMEM; - goto errOut; - } - rtn = (int)read(fd, buf, size); - if(rtn != size) { - if(rtn >= 0) { - fprintf(stderr, "readFile: short read\n"); - } - rtn = EIO; - } - else { - rtn = 0; - *bytes = (unsigned char *)buf; - *numBytes = size; - } -errOut: - close(fd); - return rtn; -}