changeset 613:15cd5b8a29b2

Add DRF_USE_STDIO flag for resources.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 12 Apr 2013 12:34:17 +0300
parents 696f03f30c0e
children eed8d6abd89b
files dmres.c dmres.h
diffstat 2 files changed, 16 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/dmres.c	Fri Apr 12 12:33:49 2013 +0300
+++ b/dmres.c	Fri Apr 12 12:34:17 2013 +0300
@@ -579,15 +579,14 @@
 #ifdef DM_USE_PACKFS
         if (handle->lib->flags & DRF_USE_PACK)
             handle->fops = &dfPackFileOps;
+
 #    ifdef DM_USE_STDIO
         else
+        if (handle->lib->flags & DRF_USE_STDIO)
             handle->fops = &dfStdioFileOps;
 #    else
         handle->fops = &dfPackFileOps;
 #    endif
-
-#else
-        handle->fops = NULL;
 #endif
 
         dmf_reset(handle);
@@ -660,13 +659,18 @@
     if ((handle = dmres_find(lib, filename)) == NULL)
     {
 #ifdef DM_USE_STDIO
-        // Hmm.. does not exist? Fall back to a stdio file
-        handle = dmres_new(lib, filename, 0, 0);
-        if (handle == NULL)
+        if (lib->flags & DRF_USE_STDIO)
+        {
+            // Hmm.. does not exist? Fall back to a stdio file
+            handle = dmres_new(lib, filename, 0, 0);
+            if (handle == NULL)
+                return NULL;
+
+            handle->fops = &dfStdioFileOps;
+            dmres_insert(lib, handle);
+        }
+        else
             return NULL;
-
-        handle->fops = &dfStdioFileOps;
-        dmres_insert(lib, handle);
 #else
         // Stdio not enabled, fail
         return NULL;
--- a/dmres.h	Fri Apr 12 12:33:49 2013 +0300
+++ b/dmres.h	Fri Apr 12 12:34:17 2013 +0300
@@ -30,8 +30,9 @@
 enum
 {
     DRF_USE_PACK    = 0x0001,
-    DRF_PRELOAD_ALL = 0x0002,
-    DRF_PRELOAD_RES = 0x0004,
+    DRF_USE_STDIO   = 0x0002,
+    DRF_PRELOAD_ALL = 0x0004,
+    DRF_PRELOAD_RES = 0x0008,
 };
 
 enum