added missing file
[public/netxms.git] / src / libnetxms / dirw_unix.c
CommitLineData
c56c93a3
VK
1/*
2 * dirw_unix.c
3 */
4
5#include "libnetxms.h"
6#include <sys/stat.h>
7
8#ifdef UNICODE
9
10/**
11 * opendir() wrapper
12 */
13DIRW *wopendir(const WCHAR *name)
14{
15 char *utf8name = UTF8StringFromWideString(name);
16 DIR *dir = opendir(utf8name);
17 free(utf8name);
18 if (dir == NULL)
19 return NULL;
20 DIRW *d = (DIRW *)malloc(sizeof(DIRW));
21 d->dir = dir;
22 return d;
23}
24
25/**
26 * readdir() wrapper
27 */
28struct dirent_w *wreaddir(DIRW *dirp)
29{
30 struct dirent *d = readdir(dirp->dir);
31 if (d == NULL)
32 return NULL;
33 MultiByteToWideChar(CP_UTF8, 0, d->d_name, -1, dirp->dirstr.d_name, 257);
34 dirp->dirstr.d_name[256] = 0;
35 dirp->dirstr.d_ino = d->d_ino;
36 return &dirp->dirstr;
37}
38
39/*
40 * closedir() wrapper
41 */
42int wclosedir(DIRW *dirp)
43{
44 closedir(dirp->dir);
45 free(dirp);
46 return 0;
47}
48
49#endif