Updated PCI IDs to latest snapshot.
[tangerine.git] / workbench / classes / zune / prefseditor / support.c
blob2d3b826b2bf9fefb67be53cbe5cb1fc6f32aab0b
1 /*
2 Copyright © 2004, The AROS Development Team. All rights reserved.
3 This file is part of the PrefsEditor class, which is distributed under
4 the terms of version 2.1 of the GNU Lesser General Public License.
6 $Id$
7 */
9 #include <exec/types.h>
10 #include <proto/dos.h>
11 #include <proto/utility.h>
12 #include <proto/exec.h>
14 #include <stdio.h>
15 #include <aros/debug.h>
17 #include "support.h"
19 /* Note: buffer *MUST* be large enough for atleast strlen(prefix) + 8 + 1 */
20 BPTR CreateTemporary(STRPTR buffer, CONST_STRPTR prefix)
22 BPTR fh;
24 while (TRUE)
26 sprintf(buffer, "%s%08lx", prefix, GetUniqueID());
27 fh = Open(buffer, MODE_NEWFILE);
29 if (fh != NULL)
31 return fh;
33 else if (IoErr() != ERROR_OBJECT_EXISTS)
35 return NULL;
40 BOOL MakeDir(CONST_STRPTR path)
42 BPTR lock = CreateDir(path);
44 if (lock != NULL)
46 UnLock(lock);
47 return TRUE;
50 return FALSE;
53 BOOL MakeDirs(STRPTR path)
55 STRPTR position;
56 BOOL success = FALSE;
57 BPTR lock = NULL;
59 for (position = path; *position != '\0'; position++)
61 if (*position == '/')
63 *position = '\0';
65 if ((lock = Lock(path, SHARED_LOCK)) != NULL)
67 UnLock(lock);
68 success = TRUE;
70 else
72 success = MakeDir(path);
75 *position = '/';
77 if (!success) return FALSE;
81 return TRUE;