2 * Mini mv implementation for busybox
4 * Copyright (C) 1998 by Erik Andersen <andersee@debian.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include <sys/types.h>
30 const char mv_usage[] = "source-file [source-file ...] destination-file\n"
31 "\n" "\tMove the source files to the destination.\n" "\n";
35 extern int mv_main (int argc, char **argv)
43 fprintf (stderr, "Usage: %s %s", *argv, mv_usage);
46 lastArg = argv[argc - 1];
48 dirFlag = isDirectory (lastArg);
50 if ((argc > 3) && !dirFlag) {
51 fprintf (stderr, "%s: not a directory\n", lastArg);
59 if (access (srcName, 0) < 0) {
67 destName = buildName (destName, srcName);
69 if (rename (srcName, destName) >= 0)
77 if (!copyFile (srcName, destName, TRUE))
80 if (unlink (srcName) < 0)