1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
/** BEGIN COPYRIGHT BLOCK
* Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
* Copyright (C) 2005 Red Hat, Inc.
* All rights reserved.
*
* License: GPL (version 3 or any later version).
* See LICENSE for details.
* END COPYRIGHT BLOCK **/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
/* fileio.c - layer to adjust EOL to use DOS format via PR_Read/Write on NT */
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/param.h>
#include <unistd.h>
#include <pwd.h>
#include "slap.h"
#include "pw.h"
#include <prio.h>
PRInt32
slapi_read_buffer(PRFileDesc *fd, void *buf, PRInt32 amount)
{
PRInt32 rval = 0;
rval = PR_Read(fd, buf, amount);
return rval;
}
/*
* slapi_write_buffer -- same as PR_Write
* except '\r' is added before '\n'.
* Return value: written bytes not including '\r' characters.
*/
PRInt32
slapi_write_buffer(PRFileDesc *fd, void *buf, PRInt32 amount)
{
PRInt32 rval = 0;
rval = PR_Write(fd, buf, amount);
return rval;
}
/*
* This function renames a file to a new name. Unlike PR_Rename or NT rename, this
* function can be used if the destfilename exists, and it will overwrite the dest
* file name
*/
int
slapi_destructive_rename(const char *srcfilename, const char *destfilename)
{
int rv = 0;
if (rename(srcfilename, destfilename) < 0) {
rv = errno;
}
return rv;
}
/*
* This function copies the source into the dest
*/
int
slapi_copy(const char *srcfilename, const char *destfilename)
{
int rv = 0;
unlink(destfilename);
if (link(srcfilename, destfilename) < 0) {
rv = errno;
}
return rv;
}
|