CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Fri, 18 Jul 2025 02:00:11 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20090210090745
location: https://web.archive.org/web/20090210090745/https://examples.oreilly.com/upt2/split/lndir.shar
server-timing: captures_list;dur=0.853131, exclusion.robots;dur=0.033041, exclusion.robots.policy;dur=0.017500, esindex;dur=0.017650, cdx.remote;dur=7.649790, LoadShardBlock;dur=331.608510, PetaboxLoader3.datanode;dur=107.092645, PetaboxLoader3.resolve;dur=59.221344
x-app-server: wwwb-app225
x-ts: 302
x-tr: 366
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: SERVER=wwwb-app225; path=/
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Fri, 18 Jul 2025 02:00:12 GMT
content-type: application/x-shar
content-length: 5493
x-archive-orig-date: Tue, 10 Feb 2009 09:07:45 GMT
x-archive-orig-server: Apache
x-archive-orig-last-modified: Mon, 31 Mar 2008 18:10:12 GMT
x-archive-orig-etag: "2272c0-1575-90194900"
x-archive-orig-accept-ranges: bytes
x-archive-orig-content-length: 5493
x-archive-orig-connection: close
cache-control: max-age=1800
x-archive-guessed-content-type: application/x-shar
x-archive-guessed-charset: utf-8
memento-datetime: Tue, 10 Feb 2009 09:07:45 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Wed, 19 Jun 2002 02:04:17 GMT", ; rel="prev memento"; datetime="Wed, 18 Oct 2006 00:12:18 GMT", ; rel="memento"; datetime="Tue, 10 Feb 2009 09:07:45 GMT", ; rel="next memento"; datetime="Wed, 30 Sep 2015 13:24:41 GMT", ; rel="last memento"; datetime="Fri, 25 Mar 2016 03:06:38 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: 52_8_20090210075601_crawl103-c/52_8_20090210090559_crawl100.arc.gz
server-timing: captures_list;dur=0.663338, exclusion.robots;dur=0.032514, exclusion.robots.policy;dur=0.021180, esindex;dur=0.015205, cdx.remote;dur=51.199410, LoadShardBlock;dur=295.784021, PetaboxLoader3.datanode;dur=352.217427, PetaboxLoader3.resolve;dur=286.604227, load_resource;dur=365.460252
x-app-server: wwwb-app225
x-ts: 200
x-tr: 742
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
accept-ranges: bytes
From: koreth@ssyx.ucsc.edu (Steven Grimm)
Newsgroups: comp.sources.misc
Subject: v02i039: Symbolic directory copier ("lndir")
Message-ID: <7174@ncoast.UUCP>
Date: 3 Feb 88 02:01:29 GMT
Approved: allbery@ncoast.UUCP
Comp.sources.misc: Volume 2, Issue 39
Submitted-By: "Steven Grimm"
Archive-Name: lndir
This is my first posting to comp.sources.unix; I assume that a posting here
will go to the moderator. If anyone gets this and I'm doing something wrong,
let me know. Thanks.
[Yes, r$ is back, and bouncing stuff as readily as ever! ;-) ++bsa]
Steven Grimm
---------- cut here ----------
# This is a shell archive. Remove anything before this line
# then unpack it by saving it in a file and typing "sh file"
# (Files unpacked will be owned by you and have default permissions).
# This archive contains the following files:
# ./lndir.c
# ./Makefile
#
if `test ! -s ./lndir.c`
then
echo "writing ./lndir.c"
cat > ./lndir.c << '\Rogue\Monster\'
#include
#include
#include
#include
char *rindex();
/*
** LNDIR
**
** Written by Steven Grimm (koreth@ssyx.ucsc.edu), 11-9-87
**
** A safe way to duplicate a directory structure elsewhere on the filesystem.
** It's necessary because a cd into a straight symbolic link actually changes
** to the directory pointed to by the link, which can be dangerous if the
** link is in a sensitive area of the filesystem. LNDIR recursively recreates
** a directory structure, making symbolic links to all the files in the
** directory.
**
** This is really pretty ugly, but was the only way to solve a few problems
** we were having.
**
** Usage: lndir srcdir [destdir]
** Where destdir is the name that you want the source directory to have
** in its new location -- that is, to link /usr/src/foo to /usr/a/xxx/foo,
** you'd do
** % lndir /usr/src/foo /usr/a/xxx/foo
** If no destination directory is specified, the new directory is given
** the same name as its original and placed in the current directory, so
** the above is equivalent to
** % cd /usr/a/xxx
** % lndir /usr/src/foo
*/
int errno; /* System error number storage. */
char errfile[1024]; /* Filename that caused the error. */
main(argc, argv)
char **argv;
{
char srcdir[1024], destdir[1024];
if (argc < 2 || argc > 3)
{
printf("Usage: %s srcdir [destdir]\n", argv[0]);
exit(-1);
}
strcpy(srcdir, argv[1]);
if (argc == 2)
{
char *sdirname;
strcpy(destdir, "./");
sdirname = rindex(srcdir, '/');
if (! sdirname)
{
printf("Can't copy a directory to itself.\n");
exit(-1);
}
strcat(destdir, sdirname+1);
}
else
strcpy(destdir, argv[2]);
if ((errno = copydir(srcdir, destdir)) < 0)
{
char error[2048];
sprintf(error, "File %s", errfile);
perror(error);
}
exit(errno);
}
/*
** Create a copy of the source directory in the destination directory, and
** create symbolic links to all the files there. If any of the files are
** directories themselves, recursively copy them into the destination
** directory using the same procedure (which is what recursive means,
** isn't it?)
*/
copydir(s, d)
char *s, *d;
{
DIR *dptr;
struct direct *file;
struct stat sbuf, sourcedir;
printf("Copying %s to %s\n", s, d);
if (stat(s, &sourcedir) == -1)
{
strcpy(errfile, s);
return errno;
}
if ((dptr = opendir(s)) == NULL)
{
strcpy(errfile, s);
return errno;
}
/* The new directory is created with mode 700, so we can write to it (just in
case the source directory isn't writeable, or umask is set to some weird
value.) It's chmodded to its original value after its contents have been
copied. */
if (mkdir(d, 0700) == -1)
{
strcpy(errfile, d);
return errno;
}
while (file = readdir(dptr))
{
char srcfile[1024], destfile[1024];
strcpy(srcfile, s);
strcat(srcfile, "/");
strcat(srcfile, file->d_name);
strcpy(destfile, d);
strcat(destfile, "/");
strcat(destfile, file->d_name);
if (stat(srcfile, &sbuf) == -1)
{
strcpy(errfile, srcfile);
return errno;
}
if (sbuf.st_mode & S_IFDIR) /* Is this a directory? */
{
if (file->d_name[0] == '.' && /* Is it . or ..? */
(file->d_name[1] == '\0' ||
(file->d_name[1] == '.' &&
file->d_name[2] == '\0')))
continue;
if (errno = copydir(srcfile, destfile))
return errno;
}
else
if (symlink(srcfile, destfile) == -1)
{
strcpy(errfile, srcfile);
return errno;
}
}
if (chmod(d, sourcedir.st_mode & 07777) == -1)
{
strcpy(errfile, d);
return errno;
}
return 0;
}
\Rogue\Monster\
else
echo "will not over write ./lndir.c"
fi
if `test ! -s ./Makefile`
then
echo "writing ./Makefile"
cat > ./Makefile << '\Rogue\Monster\'
CFLAGS = -O
lndir: lndir.c
$(CC) $(CFLAGS) lndir.c -o lndir
\Rogue\Monster\
else
echo "will not over write ./Makefile"
fi
echo "Finished archive 1 of 1"
# if you want to concatenate archives, remove anything after this line
exit
+New! Improved! Now 100% Artificial-+-+-----------------------------------+
|# # @@@ **** &&&&& $$$$$ % %| |Steven Grimm |
|# # @ @ * * & $ % %+-+ ARPA: koreth@ucscb.ucsc.edu |
|### @ @ **** &&&& $ %%%%%| | UUCP: ...!ucbvax!ucscc!ssyx!koreth|
|# # @ @ * * & $ % %+-+ ______________________________|
|# # @@@ * ** &&&&& $ % %| | |"Let's see what's out there."|
+-----with NutraSour(TM)! No natural colors or preservatives!------------+