7 const char ln_usage[] = "ln [-s] [-f] original-name additional-name\n"
9 "\tAdd a new name that refers to the same file as \"original-name\"\n"
11 "\t-s:\tUse a \"symbolic\" link, instead of a \"hard\" link.\n"
12 "\t-f:\tRemove existing destination files.\n";
15 ln_fn(const struct FileInfo * i)
19 const char * destination = i->destination;
21 if ( !i->makeSymbolicLink && (i->stat.st_mode & S_IFMT) == S_IFDIR ) {
22 fprintf(stderr, "Please use \"ln -s\" to link directories.\n");
27 * If the destination is a directory, create a file within it.
29 if ( is_a_directory(i->destination) ) {
30 destination = join_paths(
33 ,&i->source[i->directoryLength]);
37 status = ( unlink(destination) && errno != ENOENT );
40 if ( i->makeSymbolicLink )
41 status = symlink(i->source, destination);
43 status = link(i->source, destination);
47 name_and_error(destination);