added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / workbench / c / Relabel.c
blob3356a5b442e3809156e9b76e436c5699728dbb84
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 /******************************************************************************
9 NAME
11 Relabel
13 SYNOPSIS
15 DRIVE/A, NAME/A
17 LOCATION
19 Sys:C
21 FUNCTION
23 Rename a volume
25 INPUTS
27 DRIVE -- The volume to rename
28 NAME -- The new name
30 RESULT
32 NOTES
34 EXAMPLE
36 BUGS
38 SEE ALSO
40 INTERNALS
42 ******************************************************************************/
44 #include <dos/dos.h>
45 #include <dos/dosextens.h>
46 #include <dos/rdargs.h>
47 #include <dos/stdio.h>
48 #include <proto/dos.h>
49 #include <proto/exec.h>
50 #include <string.h>
52 const TEXT version[] = "$VER: Relabel 41.1 (2.6.2000)\n";
54 enum { ARG_DRIVE = 0, ARG_NAME };
56 int __nocommandline;
58 int main(void)
60 int retval = RETURN_FAIL;
61 IPTR args[] = { (IPTR) NULL, (IPTR) NULL };
62 struct RDArgs *rda;
64 rda = ReadArgs("DRIVE/A,NAME/A", args, NULL);
66 if(rda != NULL)
68 if(strchr((STRPTR)args[ARG_NAME], ':') == NULL)
70 ULONG len = strlen((STRPTR)args[ARG_DRIVE]);
71 UBYTE tmp[len + 1];
72 struct DosList *dl;
74 if (!len || ((STRPTR)args[ARG_DRIVE])[len - 1] != ':')
75 goto invalid;
77 len--;
78 memcpy(tmp, (STRPTR)args[ARG_DRIVE], len);
79 tmp[len] = '\0';
81 dl = LockDosList(LDF_READ | LDF_DEVICES | LDF_VOLUMES);
82 dl = FindDosEntry(dl, tmp, LDF_DEVICES | LDF_VOLUMES);
83 UnLockDosList(LDF_READ | LDF_DEVICES | LDF_VOLUMES);
85 if (dl)
87 if (Relabel((STRPTR)args[ARG_DRIVE], (STRPTR)args[ARG_NAME]))
89 retval = RETURN_OK;
91 else
93 PrintFault(IoErr(), NULL);
96 else
98 invalid:
99 PutStr("Invalid device or volume name\n");
103 else
105 PutStr("':' is not a valid character in a volume name.\n");
106 retval = RETURN_FAIL;
109 else
111 PrintFault(IoErr(), "Relabel");
112 retval = RETURN_FAIL;
115 FreeArgs(rda);
117 return retval;