GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
dirent-wrappers.c
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2016-2017 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 // These functions may be provided by gnulib. We don't include gnulib
24 // headers directly in Octave's C++ source files to avoid problems that
25 // may be caused by the way that gnulib overrides standard library
26 // functions.
27 
28 #if defined (HAVE_CONFIG_H)
29 # include "config.h"
30 #endif
31 
32 #include <dirent.h>
33 
34 #include "dirent-wrappers.h"
35 
36 void *
37 octave_opendir_wrapper (const char *dname)
38 {
39  return opendir (dname);
40 }
41 
42 char *
44 {
45  struct dirent *d_ent = readdir ((DIR *) dir);
46 
47  return d_ent ? d_ent->d_name : 0;
48 }
49 
50 void
52 {
53  rewinddir ((DIR *) dir);
54 }
55 
56 int
58 {
59  return closedir ((DIR *) dir);
60 }
61 
62 // Define NAME_MAX, the maximum length of a single component in a
63 // filename. No such limit may exist, or may vary depending on the
64 // filesystem. This value should be avoided for creating character
65 // strings and used only to truncate given file names to this length if
66 // attempts to get info about the file fail with errno == ENAMETOOLONG.
67 
68 // Most likely the system will truncate filenames if it is not POSIX,
69 // and so we can use the BSD value here.
70 
71 #if ! defined (_POSIX_NAME_MAX)
72 # define _POSIX_NAME_MAX 255
73 #endif
74 
75 #if ! defined (NAME_MAX)
76 # define NAME_MAX _POSIX_NAME_MAX
77 #endif
78 
79 unsigned int
81 {
82  return NAME_MAX;
83 }
unsigned int octave_name_max_wrapper(void)
#define NAME_MAX
int octave_closedir_wrapper(void *dir)
void * octave_opendir_wrapper(const char *dname)
void octave_rewinddir_wrapper(void *dir)
char * octave_readdir_wrapper(void *dir)