home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_disks
/
500-599
/
ff597.lzh
/
NewList
/
LinkStuff
/
MakeLink.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-02-01
|
2KB
|
63 lines
/* MakeLink (or NewLink ;-)
* by
* Phil Dietz -- NCEMRSoft
*
* USAGE: MakeLink <link name> <file name> [hard | soft]
*
* EXAMPLE: MakeLink df1:link df1:source/NewList hard
* MakeLink df1:link df1:source/NewList soft
*
* SUMMARY: Makes both hard AND soft links which Commodore's
* MakeLink fails to do. Files and dirs are supported.
*
* TIPS: Always try to make hard links when possible. If your
* filesystem doesn't like hard-links, you can resort
* to softlinks. Softlinks are more prone to errors.
* If you accidently delete the file the soft link points to,
* you'll have a file that can only be deleted with
* 'deletelink'. HOWEVER, softlinks do offer a bonus.
* They may point across filesystems (ie points to dh0:
* from df1:!) They are pretty neat when used right!
*
* NOTES: Works only under wb2.0 version 37.
*
* COMPILE: lc -Lt -ccurfist -rr -ms -O -v -b1 MakeLink.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <dos/dos.h>
#include <dos/dosextens.h>
#include <clib/dos_protos.h>
#include <clib/exec_protos.h>
#include <pragmas/dos_pragmas.h>
#include <pragmas/exec_pragmas.h>
extern struct DOSBase *DOSBase;
extern struct SysBase *SysBase;
int main(int argc, char **argv)
{
BPTR lock1;
if (!(struct DosLibrary *)OpenLibrary("dos.library", 37)) exit(1);
if (argc<4)
{
PutStr("Usage: MakeLink <link name> <file name> [hard | soft]\n");
exit(1);
}
if (*argv[3]=='h') /* Do hard-link stuff */
{
lock1=Lock(argv[2],SHARED_LOCK); /* Fetch needed lock */
if (lock1)
{
if (!(MakeLink(argv[1],lock1,FALSE))) PutStr("Hard link failed.\n");
else UnLock(lock1);
}
else Printf("Couldn't lock %s.\n",argv[2]);
}
else /* do soft-link stuff instead */
if (!(MakeLink(argv[1],(CPTR)argv[2],TRUE))) PutStr("Soft link failed.\n");
}