Support rastport clipping rectangle for layerless rastports
[tangerine.git] / rom / dos / makelink.c
blob597fe9fa6765863f64f3b8caae70b492cc9d5d7a
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Create a hard- or softlink.
6 Lang: English
7 */
8 #include <dos/dosextens.h>
9 #include <dos/filesystem.h>
10 #include "dos_intern.h"
11 #include <proto/exec.h>
13 /*****************************************************************************
15 NAME */
16 #include <exec/types.h>
17 #include <proto/dos.h>
19 AROS_LH3(LONG, MakeLink,
21 /* SYNOPSIS */
22 AROS_LHA(STRPTR, name, D1),
23 AROS_LHA(APTR, dest, D2),
24 AROS_LHA(LONG , soft, D3),
26 /* LOCATION */
27 struct DosLibrary *, DOSBase, 74, Dos)
29 /* FUNCTION
30 MakeLink() will create a link between two files or directories.
31 A link is a filesystem object that refers to another file.
33 A soft link refers to another file by name, and is resolved by
34 the filesystem and the caller. Soft links are not restricted to
35 the same volume. The |dest| argument is a NUL terminated pathname
36 to the pre-existing object. Soft links can be used on directories.
38 A hard link refers to another file by the location on a disk, and
39 is resolved by the filesystem. Hard links are restricted to files
40 on the same volume. The |dest| argument is a lock on another file.
42 INPUTS
43 name - The name of the link to create
44 dest - If 'soft' is TRUE this must be a filename, if it is FALSE a BPTR
45 pointing to the file to be hard-linked must be provided
46 soft - TRUE, if a soft-link is to be created, FALSE for an hard-link
48 RESULT
49 boolean - DOSTRUE or DOSFALSE. On error, IoErr() will contain more
50 information.
52 NOTES
54 EXAMPLE
56 BUGS
57 Soft links were not working in the ROM filesystem before version
58 37.
60 SEE ALSO
61 ReadLink()
63 INTERNALS
64 This function calls either FSA_CREATE_HARDLINK or FSA_CREATE_SOFTLINK
65 on the filesystem of `name`.
67 *****************************************************************************/
69 AROS_LIBFUNC_INIT
70 AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
71 LONG error;
72 struct Device *dev;
73 struct Process *me=(struct Process *)FindTask(NULL);
74 struct IOFileSys io;
76 io.IOFS.io_Message.mn_Node.ln_Type = NT_REPLYMSG;
77 io.IOFS.io_Message.mn_ReplyPort = &me->pr_MsgPort;
78 io.IOFS.io_Message.mn_Length = sizeof(struct IOFileSys);
79 io.IOFS.io_Flags = 0;
80 if (soft)
82 /* We want a soft-link. */
83 io.IOFS.io_Command = FSA_CREATE_SOFTLINK;
84 io.io_Union.io_CREATE_SOFTLINK.io_Reference = (STRPTR)dest;
85 } else
87 /* We want a hard-link. */
88 struct FileHandle *fh = (struct FileHandle *)BADDR((BPTR)dest);
89 /* We check, if name and dest are on the same device. */
90 if (DevName(name, &dev, DOSBase))
91 return DOSFALSE;
92 if (dev != fh->fh_Device)
94 SetIoErr(ERROR_RENAME_ACROSS_DEVICES);
95 return DOSFALSE;
97 io.IOFS.io_Command = FSA_CREATE_HARDLINK;
98 io.io_Union.io_CREATE_HARDLINK.io_OldFile = fh->fh_Unit;
101 error = DoName(&io, name, DOSBase);
102 if (error)
104 SetIoErr(error);
105 return DOSFALSE;
108 return DOSTRUE;
109 AROS_LIBFUNC_EXIT
110 } /* MakeLink */