1212
1313#include "xlswriter.h"
1414#include "ext/date/php_date.h"
15- #include "ext/standard/php_filestat.h"
1615
1716zend_class_entry * vtiful_xls_ce ;
1817
@@ -278,7 +277,7 @@ PHP_METHOD(vtiful_xls, __construct)
278277PHP_METHOD (vtiful_xls , fileName )
279278{
280279 char * sheet_name = NULL ;
281- zval file_path , dir_exists , * dir_path = NULL ;
280+ zval file_path , * dir_path = NULL ;
282281 zend_string * zs_file_name = NULL , * zs_sheet_name = NULL ;
283282
284283 ZEND_PARSE_PARAMETERS_START (1 , 2 )
@@ -287,16 +286,13 @@ PHP_METHOD(vtiful_xls, fileName)
287286 Z_PARAM_STR (zs_sheet_name )
288287 ZEND_PARSE_PARAMETERS_END ();
289288
290- ZVAL_NULL (& dir_exists );
291289 ZVAL_COPY (return_value , getThis ());
292290
293291 GET_CONFIG_PATH (dir_path , vtiful_xls_ce , return_value );
294292
295- php_stat (ZSTR_VAL (Z_STR_P (dir_path )), strlen (ZSTR_VAL (Z_STR_P (dir_path ))), FS_IS_DIR , & dir_exists );
296-
297- if (Z_TYPE (dir_exists ) == IS_FALSE ) {
298- zval_ptr_dtor (& dir_exists );
293+ if (directory_exists (ZSTR_VAL (Z_STR_P (dir_path ))) == XLSWRITER_FALSE ) {
299294 zend_throw_exception (vtiful_exception_ce , "Configure 'path' directory does not exist" , 121 );
295+ return ;
300296 }
301297
302298 xls_object * obj = Z_XLS_P (getThis ());
@@ -315,8 +311,6 @@ PHP_METHOD(vtiful_xls, fileName)
315311
316312 zval_ptr_dtor (& file_path );
317313 }
318-
319- zval_ptr_dtor (& dir_exists );
320314}
321315/* }}} */
322316
0 commit comments