grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / libs / icon / deletediskobject.c
blob11791626c01e42d87a7bf413d2c29fcd6b0e2cde
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
8 #include <proto/dos.h>
9 #include <proto/workbench.h>
10 #include "icon_intern.h"
12 /*****************************************************************************
14 NAME */
15 #include <proto/icon.h>
17 AROS_LH1(BOOL, DeleteDiskObject,
19 /* SYNOPSIS */
20 AROS_LHA(UBYTE *, name, A0),
22 /* LOCATION */
23 struct IconBase *, IconBase, 23, Icon)
25 /* FUNCTION
26 Deletes an icon description file.
28 INPUTS
29 name - name of the icon file without the ".info".
31 RESULT
33 NOTES
35 EXAMPLE
37 BUGS
39 SEE ALSO
41 INTERNALS
43 HISTORY
45 *****************************************************************************/
47 AROS_LIBFUNC_INIT
48 UBYTE * infofilename;
49 BOOL success = FALSE;
50 BPTR lock, parent;
51 LONG ioerr;
53 if (!(infofilename = (UBYTE*)AllocVec (strlen(name) + 6,
54 MEMF_ANY | MEMF_CLEAR)
55 ) )
56 return (FALSE);
58 /* Construct the icon's name */
59 strcpy (infofilename, name);
60 strcat (infofilename, ".info");
62 lock = Lock(infofilename, SHARED_LOCK);
63 if (lock) {
64 parent = ParentDir(lock);
65 UnLock(lock); // DeleteFile() fails on locked files
66 if (parent) {
67 success = DeleteFile (infofilename);
68 if (success && WorkbenchBase) {
69 UpdateWorkbench(FilePart(name), parent, UPDATEWB_ObjectRemoved);
71 ioerr = IoErr(); // UnLock() resets error
72 UnLock(parent);
73 SetIoErr(ioerr);
77 FreeVec (infofilename);
79 return success;
80 AROS_LIBFUNC_EXIT
81 } /* DeleteDiskObject */