summaryrefslogtreecommitdiff
path: root/graphics/opencv2/patches/patch-modules_contrib_src_inputoutput.cpp
blob: 22c7b91b3de47b45f39c39d99104486f663bcad0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
$NetBSD: patch-modules_contrib_src_inputoutput.cpp,v 1.1 2015/10/17 10:28:43 fhajny Exp $

SunOS does not have dirent d_type.

--- modules/contrib/src/inputoutput.cpp.orig	2015-02-25 12:10:31.000000000 +0000
+++ modules/contrib/src/inputoutput.cpp
@@ -6,6 +6,9 @@
     #include <windows.h>
     #include <tchar.h>
 #else
+#ifdef __sun
+    #include <sys/stat.h>
+#endif
     #include <dirent.h>
 #endif
 
@@ -72,6 +75,10 @@ namespace cv
             (void)addPath;
             DIR *dp;
             struct dirent *dirp;
+#ifdef __sun
+            struct stat sb;
+            char buf[PATH_MAX];
+#endif
             if((dp = opendir(path.c_str())) == NULL)
             {
                 return list;
@@ -96,6 +103,10 @@ namespace cv
                      extra = _DEXTRA_NEXT(extra),
                      extra_stat = reinterpret_cast<dirent_extra_stat *>(extra))
                 if ((extra->d_type != _DTYPE_NONE) && S_ISREG(extra_stat->d_stat.st_mode))
+            #elif defined(__sun)
+                snprintf(buf, PATH_MAX, "%s/%s", path.c_str(), dirp->d_name);
+                stat(buf, &sb);
+                if (S_ISREG(sb.st_mode))
             #else
                 if (dirp->d_type == DT_REG)
             #endif
@@ -181,6 +192,10 @@ namespace cv
             (void)addPath;
             DIR *dp;
             struct dirent *dirp;
+#ifdef __sun
+            struct stat sb;
+            char buf[PATH_MAX];
+#endif
             if((dp = opendir(path_f.c_str())) == NULL)
             {
                 return list;
@@ -206,6 +221,10 @@ namespace cv
                      extra_stat = reinterpret_cast<dirent_extra_stat *>(extra))
                 if ((extra->d_type != _DTYPE_NONE) &&
                     S_ISDIR(extra_stat->d_stat.st_mode) &&
+            #elif defined(__sun)
+                snprintf(buf, PATH_MAX, "%s/%s", path.c_str(), dirp->d_name);
+                stat(buf, &sb);
+                if (S_ISDIR(sb.st_mode) &&
             #else
                 if (dirp->d_type == DT_DIR &&
             #endif