libite/copyfile.c
/**
 * movefile - Move a file to another location
 * @src: Source file.
 * @dst: Target file, or location.
 *
 * This is a C implementation of the command line mv(1) utility.
 * Usually the rename() API is sufficient, but not when moving across
 * file system boundaries.
 *
 * The @src argument must include the full path to the source file,
 * whereas the @dst argument may only be a directory, in which case the
 * same file name from @src is used.
 *
 * Returns:
 * POSIX OK(0), or non-zero with errno set.
 */
Move a file to another location
@src: Source file.
@dst: Target file, or location.

This is a C implementation of the command line mv(1) utility.
Usually the rename() API is sufficient, but not when moving across
file system boundaries.

The @src argument must include the full path to the source file,
whereas the @dst argument may only be a directory, in which case the
same file name from @src is used.

POSIX OK(0), or non-zero with errno set.
Move a file to another location @src : Source file . @dst : Target file or location . This is a C implementation of the command line mv ( 1 ) utility . Usually the rename () API is sufficient but not when moving across file system boundaries . The @src argument must include the full path to the source file whereas the @dst argument may only be a directory in which case the same file name from @src is used . POSIX OK ( 0 ) or non - zero with errno set .
int movefile(char *src, char *dst)
{
	int isdir, result = 0;
	isdir = adjust_target(src, &dst);
	if (rename(src, dst)) {
		if (errno == EXDEV) {
			errno = 0;
			copyfile(src, dst, 0, 1);
			if (errno)
				result = 1;
			else
				result = remove(src);
		} else {
			result = 1;
		}
	}
	if (isdir)
		free(dst);
	return result;
}
int movefile ( char * src , char * dst ) { int isdir , result = 0 ; isdir = adjust_target ( src , & dst ) ; if ( rename ( src , dst ) ) { if ( errno == EXDEV ) { errno = 0 ; copyfile ( src , dst , 0 , 1 ) ; if ( errno ) result = 1 ; else result = remove ( src ) ; } else { result = 1 ; } } if ( isdir ) free ( dst ) ; return result ; }
movefile - Move a file to another location
 @src: Source file.
movefile - Move a file to another location @src : Source file .
/* Check if target is a directory, then append the src base filename. */