1%%	options
2
3copyright owner	=	Dirk Krause
4copyright year	=	2015-xxxx
5SPDX-License-Identifier:	BSD-3-Clause
6
7
8%%	header
9
10/**	@file
11	File name expander.
12
13	CRT on Windows: Optional.
14*/
15
16#ifndef DK4CONF_H_INCLUDED
17#if DK4_BUILDING_DKTOOLS4
18#include "dk4conf.h"
19#else
20#include <dktools-4/dk4conf.h>
21#endif
22#endif
23
24#ifndef DK4DIR_H_INCLUDED
25#if DK4_BUILDING_DKTOOLS4
26#include <libdk4c/dk4dir.h>
27#else
28#include <dktools-4/dk4dir.h>
29#endif
30#endif
31
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37/**	Expand a file name.
38	@param	pattern	File name pattern, may optionally include
39	a directory part.
40	@param	erp	Error report, may be NULL.
41	@return	Directory structure on success, NULL on error.
42	On success the path component in the returned directory structure
43	is NULL if the pattern did not contain a directory part.
44
45	Error codes:
46	- DK4_E_INVALID_ARGUMENTS<br>
47	  if path is NULL,
48	- DK4_E_NOT_SUPPORTED<br>
49	  if no function to traverse directories was found during build
50	  process or the function is called on a non-Windows system,
51	- DK4_E_MEMORY_ALLOCATION_FAILED<br>
52	  if a memory allocation failed,
53	- DK4_E_MATH_OVERFLOW<br>
54	  if a mathematical overflow occured in a size calculation,
55	- DK4_E_BUFFER_TOO_SMALL<br>
56	  if one of the involved directory or file names is too long for an
57	  internal buffer,
58	- DK4_E_OPENDIR_FAILED<br>
59	  with errno value in iDetails1 if the attempt to open the directory
60	  failed,
61	- DK4_E_FINDFIRSTFILE_FAILED<br>
62	  with GetLastError() value in lDetails1 if the FindFirstFile()
63	  function failed on Windows,
64	- DK4_E_SYSTEM<br>
65	  if the stat() or lstat() function failed for one of the directory
66	  items.
67*/
68dk4_dir_t *
69dk4fne_open(const dkChar *pattern, dk4_er_t *erp);
70
71#ifdef __cplusplus
72}
73#endif
74
75
76
77%%	module
78
79#include "dk4conf.h"
80#include <libdk4c/dk4fne.h>
81
82#if DK4_CHAR_SIZE > 1
83#ifndef DK4FNEWC_H_INCLUDED
84#include <libdk4c/dk4fnewc.h>
85#endif
86#else
87#ifndef DK4FNE08_H_INCLUDED
88#include <libdk4c/dk4fne08.h>
89#endif
90#endif
91
92#if	DK4_HAVE_ASSERT_H
93#ifndef	ASSERT_H_INCLUDED
94#include <assert.h>
95#define	ASSERT_H_INCLUDED 1
96#endif
97#endif
98
99
100dk4_dir_t *
101dk4fne_open(const dkChar *pattern, dk4_er_t *erp)
102{
103#if	DK4_USE_ASSERT
104  assert(NULL != pattern);
105#endif
106#if DK4_CHAR_SIZE > 1
107  return (dk4fne_open_wc(pattern, erp));
108#else
109  return (dk4fne_open_c8(pattern, erp));
110#endif
111}
112
113