4 * Copy files about an Acorn system
6 * © 1998 Straylight/Edgeware
9 /*----- Licensing note ----------------------------------------------------*
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2, or (at your option)
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, write to the Free Software Foundation,
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 /*----- Header files ------------------------------------------------------*/
38 /*----- Install programs --------------------------------------------------*/
40 static int exitstat = 0; /* Exit status */
44 * Arguments: @const char *s@ = pointer to source filename
45 * @const char *d@ = pointer to destination filename
52 static void copy(const char *s, const char *d)
56 e = _swix(OS_FSControl, _inr(0, 3), 26, s, d, 0x1002);
58 fprintf(stderr, "inst: error copying `%s' to `%s': %s\n",
66 * Arguments: @int argc@ = number of arguments
67 * @char *argv[]@ = list of arguments
69 * Returns: Zero if all went well
71 * Use: Installs files in the right places. This is a bit of a
72 * rip-off of unix `cp'.
75 int main(int argc, char *argv[])
80 /* --- Expand wildcards in the arguments --- */
82 cmdreplace(&argc, &argv);
84 /* --- Report an error if there aren't enough arguments --- */
89 " inst SRCFILE DSTFILE\n"
90 " inst SRCFILE [SRCFILE...] DSTDIR\n");
94 /* --- Sort out how to copy things --- */
97 ty = _swi(OS_File, _inr(0, 1) | _return(0), 17, d);
99 if (ty < 2 && argc > 3) {
101 "inst: too many files; destination is not a directory\n");
105 /* --- Do the copying --- */
107 if ((ty & 1 || ty == 0) && argc == 3)
108 copy(argv[1], argv[2]);
111 size_t sz = strlen(d);
117 for (i = 1; i < argc - 1; i++) {
118 char *p = strrchr(argv[i], '.');
119 if (p) p++; else p = argv[i];
120 strcpy(buf + sz + 1, p);
130 /*----- That's all, folks -------------------------------------------------*/