commit ee3942c7f94d163141428ce8a78d6797ee8ae196
parent b24b7eb2b0e983fc7b1e56a64375b9623db8ae2e
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Tue, 20 Oct 2015 16:08:04 +0200
Handle relative filename in the optical_properties_load function
Diffstat:
1 file changed, 22 insertions(+), 0 deletions(-)
diff --git a/src/sbox_schiff_optical_properties.c b/src/sbox_schiff_optical_properties.c
@@ -26,6 +26,8 @@
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms. */
+#define _POSIX_C_SOURCE 200112L /* wordexp support */
+
#include "sbox_schiff_optical_properties.h"
#include <star/sbox.h>
@@ -33,6 +35,10 @@
#include <rsys/stretchy_array.h>
+#ifndef COMPILER_CL
+ #include <wordexp.h>
+#endif
+
/*******************************************************************************
* Helper functions
******************************************************************************/
@@ -108,7 +114,23 @@ sbox_schiff_optical_properties_load
res_T res = RES_OK;
ASSERT(sbox && filename && out_props);
+#ifdef COMPILER_CL
fp = fopen(filename, "r");
+#else
+ {
+ wordexp_t wexp;
+ int err = wordexp(filename, &wexp, 0);
+ if(err) {
+ logger_print(&sbox->logger, LOG_ERROR,
+ "Error parsing the filenames `%s'\n", filename);
+ res = RES_BAD_ARG;
+ goto error;
+ }
+ ASSERT(wexp.we_wordc == 1);
+ fp = fopen(wexp.we_wordv[0], "r");
+ wordfree(&wexp);
+ }
+#endif
if(!fp) {
logger_print(&sbox->logger, LOG_ERROR,
"Cannot open the file of Schiff optical properties `%s'.\n", filename);