-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.c
31 lines (26 loc) · 1.41 KB
/
common.c
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
/*
+----------------------------------------------------------------------+
| XlsWriter Extension |
+----------------------------------------------------------------------+
| Copyright (c) 2017-2018 The Viest |
+----------------------------------------------------------------------+
| http://www.viest.me |
+----------------------------------------------------------------------+
| Author: viest <[email protected]> |
+----------------------------------------------------------------------+
*/
#include "xlswriter.h"
void xls_file_path(zend_string *file_name, zval *dir_path, zval *file_path)
{
zend_string *full_path, *zstr_path;
zstr_path = zval_get_string(dir_path);
if (Z_STRVAL_P(dir_path)[Z_STRLEN_P(dir_path)-1] == '/') {
full_path = zend_string_extend(zstr_path, ZSTR_LEN(zstr_path) + ZSTR_LEN(file_name), 0);
memcpy(ZSTR_VAL(full_path)+ZSTR_LEN(zstr_path), ZSTR_VAL(file_name), ZSTR_LEN(file_name)+1);
} else {
full_path = zend_string_extend(zstr_path, ZSTR_LEN(zstr_path) + ZSTR_LEN(file_name) + 1, 0);
ZSTR_VAL(full_path)[ZSTR_LEN(zstr_path)] ='/';
memcpy(ZSTR_VAL(full_path)+ZSTR_LEN(zstr_path)+1, ZSTR_VAL(file_name), ZSTR_LEN(file_name)+1);
}
ZVAL_STR(file_path, full_path);
}