[libbluray-devel] Avoid using stat() outside of posix wrappers

hpi1 git at videolan.org
Fri Aug 2 16:23:50 CEST 2013


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Fri Aug  2 17:15:20 2013 +0300| [1bb20d713625681099c8c5907b48c6aa56d3fb4e] | committer: hpi1

Avoid using stat() outside of posix wrappers

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=1bb20d713625681099c8c5907b48c6aa56d3fb4e
---

 src/libbluray/bdj/bdj.c |   16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/libbluray/bdj/bdj.c b/src/libbluray/bdj/bdj.c
index d44830a..b03eed4 100644
--- a/src/libbluray/bdj/bdj.c
+++ b/src/libbluray/bdj/bdj.c
@@ -38,14 +38,10 @@
 #include "libbluray/bdj/native/register_native.h"
 
 #include <jni.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
-// stat
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
 typedef jint (JNICALL * fptr_JNI_CreateJavaVM) (JavaVM **pvm, void **penv,void *args);
 
 static void *_jvm_dlopen(const char *java_home, const char *jvm_dir, const char *jvm_lib)
@@ -125,7 +121,7 @@ static const char *_find_libbluray_jar(void)
 
     static const char *classpath = NULL;
 
-    struct stat sb;
+    FILE *fp;
     unsigned i;
 
     // check if overriding the classpath
@@ -143,7 +139,9 @@ static const char *_find_libbluray_jar(void)
     if (lib_path) {
         char *cp = str_printf("%s" BDJ_JARFILE, lib_path);
         BD_DEBUG(DBG_BDJ, "Checking %s ...\n", cp);
-        if (!stat(cp, &sb)) {
+        fp = fopen(cp, "rb")
+        if (fp) {
+            fclose(fp);
             classpath = cp;
             BD_DEBUG(DBG_BDJ, "using %s\n", cp);
             return cp;
@@ -154,7 +152,9 @@ static const char *_find_libbluray_jar(void)
     // check pre-defined directories
     for (i = 0; i < sizeof(jar_paths) / sizeof(jar_paths[0]); i++) {
         BD_DEBUG(DBG_BDJ, "Checking %s ...\n", jar_paths[i]);
-        if (!stat(jar_paths[i], &sb)) {
+        fp = fopen(cp, "rb")
+        if (fp) {
+            fclose(fp);
             classpath = jar_paths[i];
             BD_DEBUG(DBG_BDJ, "using %s\n", classpath);
             return classpath;



More information about the libbluray-devel mailing list