#define MAXPATHLEN 2048
#endif
+#ifdef __CYGWIN32__
+#include <sys/cygwin.h>
+#endif
+
#if NeedVarargsPrototypes
#include <stdarg.h>
#endif
char *rcurdir;
char *curdir;
+int force=0;
+
void
quit (
#if NeedVarargsPrototypes
#endif
{
/* directory */
+#ifndef __CYGWIN32__ /* don't trust cygwin's n_dirs count */
n_dirs--;
+#endif
if (dp->d_name[0] == '.' &&
(dp->d_name[1] == '\0' || (dp->d_name[1] == '.' &&
dp->d_name[2] == '\0')))
}
if (symlen >= 0) {
- /* Link exists in new tree. Print message if it doesn't match. */
- if (!equivalent (basesymlen>=0 ? basesym : buf, symbuf))
- msg ("%s: %s", dp->d_name, symbuf);
- } else {
- if (symlink (basesymlen>=0 ? basesym : buf, dp->d_name) < 0)
+ if (!equivalent (basesymlen>=0 ? basesym : buf, symbuf)) {
+ if (force) {
+ unlink(dp->d_name);
+ if (symlink (basesymlen>=0 ? basesym : buf, dp->d_name) < 0)
mperror (dp->d_name);
+ } else {
+ /* Link exists in new tree. Print message if it doesn't match. */
+ msg ("%s: %s", dp->d_name, symbuf);
+ }
+ }
+ } else {
+ if (symlink (basesymlen>=0 ? basesym : buf, dp->d_name) < 0)
+ mperror (dp->d_name);
}
}
-
+
closedir (df);
return 0;
}
char **av;
{
char *prog_name = av[0];
- char *fn, *tn;
+ char* tn;
struct stat fs, ts;
- int force=0;
+#ifdef __CYGWIN32__
+ /*
+ The lndir code assumes unix-style paths to work. cygwin
+ lets you get away with using dos'ish paths (e.g., "f:/oo")
+ in most contexts. Using them with 'lndir' will seriously
+ confuse the user though, so under-the-hood, we convert the
+ path into something POSIX-like.
+ */
+ static char fn[MAXPATHLEN+1];
+#else
+ char *fn;
+#endif
while (++av, --ac) {
if (strcmp(*av, "-silent") == 0)
quit (1, "usage: %s [-f] [-silent] [-ignorelinks] fromdir [todir]",
prog_name);
+#ifdef __CYGWIN32__
+ cygwin_conv_to_full_posix_path(av[0], fn);
+#else
fn = av[0];
+#endif
+
if (ac == 2)
tn = av[1];
else