#include "cuFileIo.h"
int writeFile(
+ const char *fileName,
+ const unsigned char *bytes,
+ unsigned numBytes)
+{
+ size_t n = numBytes;
+ return writeFileSizet(fileName, bytes, n);
+}
+
+int writeFileSizet(
const char *fileName,
const unsigned char *bytes,
- unsigned numBytes)
+ size_t numBytes)
{
int rtn;
int fd;
fd = open(fileName, O_RDWR | O_CREAT | O_TRUNC, 0600);
- if(fd < 0) {
- return errno;
- }
- rtn = (int)lseek(fd, 0, SEEK_SET);
- if(rtn < 0) {
+ if(fd == -1) {
return errno;
}
rtn = (int)write(fd, bytes, (size_t)numBytes);
*numBytes = 0;
*bytes = NULL;
fd = open(fileName, O_RDONLY, 0);
- if(fd < 0) {
+ if(fd == -1) {
return errno;
}
rtn = fstat(fd, &sb);