wip commit. acpi button driver.
[AROS.git] / compiler / arossupport / isdosentrya.c
blob9a1fbfe8deba2b7332cb3c1eb303ffcc0b1ebabc
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <proto/arossupport.h>
7 #include <proto/dos.h>
8 #include <proto/utility.h>
10 #include <aros/system.h>
11 #include <dos/dos.h>
13 #include <dos/dosextens.h>
14 #include <exec/types.h>
15 #include <utility/utility.h>
17 #define BUFFER_SIZE 100
19 /*****************************************************************************
21 NAME */
23 BOOL IsDosEntryA(
25 /* SYNOPSIS */
27 char * Name,
28 ULONG Flags)
30 /* LOCATION */
32 /* FUNCTION
34 There is a need in file/directory processing where an application
35 may need to determine whether a path is just a volume/device or
36 assignment name.
38 INPUTS
40 Name - The path to test.
42 Flags - Any combination of the following:
44 LDF_ASSIGNS
45 LDF_DEVICES
46 LDF_VOLUMES
48 RESULT
50 Boolean True or False.
52 NOTES
54 Requires the programmer to open the utility.library and initialise
55 UtilityBase.
57 In future releases the buffer size will be set via a taglist.
59 EXAMPLE
61 BOOL Success;
63 ...
65 Success = IsDosEntryA("Work:", LDF_VOLUMES)
66 if (Success == TRUE)
68 ...
71 BUGS
73 SEE ALSO
75 <dos/dosextens.h>
77 INTERNALS
79 HISTORY
81 27-Jul-1997 laguest Initial inclusion into the AROS tree
83 ******************************************************************************/
85 struct DosList *DList;
86 char *DLName;
87 int Position;
88 int Success;
89 BOOL ReturnValue;
90 char Buffer[BUFFER_SIZE + 1];
91 APTR DOSBase;
92 APTR UtilityBase;
94 DOSBase = OpenLibrary("dos.library", 0);
95 if (DOSBase == NULL)
96 return FALSE;
98 UtilityBase = OpenLibrary("utility.library", 0);
99 if (UtilityBase == NULL) {
100 CloseLibrary(DOSBase);
101 return FALSE;
104 ReturnValue = FALSE;
106 Position = SplitName(Name, ':', &Buffer[0], 0, BUFFER_SIZE + 1);
107 if (Position != -1 && Name[Position] == 0)
109 DList = AttemptLockDosList(Flags | LDF_READ);
110 if (DList != NULL)
112 DList = NextDosEntry(DList, Flags);
113 while (DList != NULL && ReturnValue == FALSE)
115 DLName = AROS_BSTR_ADDR(DList->dol_Name);
117 Success = Strnicmp(DLName, &Buffer[0], Position - 1);
118 if (Success == 0)
120 ReturnValue = TRUE;
123 DList = NextDosEntry(DList, Flags);
126 UnLockDosList(Flags | LDF_READ);
130 CloseLibrary(UtilityBase);
131 CloseLibrary(DOSBase);
132 return (ReturnValue);
134 } /* IsDosEntry */