From e741094cf3481b358cb256ea69d2973d85ac12d2 Mon Sep 17 00:00:00 2001
From: wlott <wlott>
Date: Wed, 6 Nov 1991 22:17:29 +0000
Subject: [PATCH] Initial revision

---
 tools/dupsrcs.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 82 insertions(+)
 create mode 100644 tools/dupsrcs.c

diff --git a/tools/dupsrcs.c b/tools/dupsrcs.c
new file mode 100644
index 000000000..dfe0974e5
--- /dev/null
+++ b/tools/dupsrcs.c
@@ -0,0 +1,82 @@
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/dir.h>
+#include <sys/stat.h>
+#include <sys/errno.h>
+#include <sys/param.h>
+
+/* Duplicates a source tree. */
+
+/* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/tools/Attic/dupsrcs.c,v 1.1 1991/11/06 22:17:29 wlott Exp $ */
+
+void duptree(srcdir, dstdir)
+char *srcdir, *dstdir;
+{
+    DIR *dir;
+    struct direct *entry;
+    char srcpath[MAXPATHLEN], dstpath[MAXPATHLEN];
+    struct stat buf;
+
+    /* Make sure the dstdir is there. */
+    if (mkdir(dstdir) == 0)
+	printf("Creating %s\n", dstdir);
+
+    dir = opendir(srcdir);
+    if (dir == NULL) {
+	perror(srcdir);
+	return;
+    }
+
+    while ((entry = readdir(dir)) != NULL) {
+	if (strncmp(entry->d_name, "RCS", 3) == 0)
+	    continue;
+	if (entry->d_name[0] == '.')
+	    continue;
+	sprintf(srcpath, "%s/%s", srcdir, entry->d_name);
+	sprintf(dstpath, "%s/%s", dstdir, entry->d_name);
+	if (stat(srcpath, &buf) < 0) {
+	    perror(srcpath);
+	    continue;
+	}
+	if ((buf.st_mode & S_IFMT) == S_IFDIR)
+	    duptree(srcpath, dstpath);
+	else
+	    if (symlink(srcpath, dstpath) == 0)
+		printf("Linked %s\n", dstpath);
+	    else
+		if (errno != EEXIST)
+		    perror(dstpath);
+    }
+
+    closedir(dir);
+}
+
+main(argc, argv)
+int argc;
+char *argv[];
+{
+    char *subdir;
+    char srcdir[MAXPATHLEN], dstdir[MAXPATHLEN];
+
+    if (argc > 2) {
+	fprintf(stderr, "usage: dupsrcs [ subdir ]\n");
+	exit(1);
+    }
+
+    if (argc == 2)
+	subdir = argv[1];
+    else
+	subdir = "alpha";
+
+    getwd(dstdir);
+
+    sprintf(srcdir, "/afs/cs/project/clisp/src/%s", subdir);
+    if (chdir(srcdir) < 0) {
+	perror(srcdir);
+	exit(1);
+    }
+    getwd(srcdir);
+
+    printf("Duplicating %s\n  into %s\n", srcdir, dstdir);
+    duptree(srcdir, dstdir);
+}
-- 
GitLab