2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2011 - DIGITEO - Calixte DENIZET
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
16 #include "charEncoding.h"
18 #include <sys/types.h>
24 #include "fileutils.h"
27 /*--------------------------------------------------------------------------*/
29 int isEmptyDirectory(char * dirName)
31 wchar_t *wcpath = NULL;
32 wchar_t wdirpath[PATH_MAX + FILENAME_MAX + 1];
34 WIN32_FIND_DATAW FileInformation;
37 wcpath = to_wide_string(dirName);
38 swprintf(wdirpath, wcslen(wcpath) + 2 + 1, L"%s\\*", wcpath);
41 hFile = FindFirstFileW(wdirpath, &FileInformation);
43 if (hFile == INVALID_HANDLE_VALUE)
50 if (!wcscmp(FileInformation.cFileName, L".") || !wcscmp(FileInformation.cFileName, L".."))
57 } while (FindNextFileW(hFile, &FileInformation) == TRUE);
63 /*--------------------------------------------------------------------------*/
65 /*--------------------------------------------------------------------------*/
66 int isEmptyDirectory(char * dirName)
71 struct dirent *result;
74 struct dirent64 *result;
78 dir = opendir(dirName);
85 ptr = MALLOC(sizeof(struct dirent) + (PATH_MAX + 1));
87 ptr = MALLOC(sizeof(struct dirent64) + (PATH_MAX + 1));
96 while ((readdir_r(dir, ptr, &result) == 0) && (result != NULL))
98 while ((readdir64_r(dir, ptr, &result) == 0) && (result != NULL))
101 if (!strcmp(ptr->d_name, ".") || !strcmp(ptr->d_name, ".."))