| 125 | | wi_string_t * wi_file_temporary_path_with_prefix(wi_string_t *prefix) { |
|---|
| 126 | | return wi_file_temporary_path_with_prefix_in_directory(prefix, NULL); |
|---|
| 127 | | } |
|---|
| 128 | | |
|---|
| 129 | | |
|---|
| 130 | | |
|---|
| 131 | | wi_string_t * wi_file_temporary_path_with_prefix_in_directory(wi_string_t *prefix, wi_string_t *tmpdir) { |
|---|
| 132 | | wi_string_t *string; |
|---|
| 133 | | char *path; |
|---|
| 134 | | |
|---|
| 135 | | path = tempnam(tmpdir ? wi_string_cstring(tmpdir) : NULL, wi_string_cstring(prefix)); |
|---|
| 136 | | string = wi_string_with_cstring(path); |
|---|
| 137 | | free(path); |
|---|
| 138 | | |
|---|
| 139 | | return string; |
|---|
| | 125 | wi_string_t * wi_file_temporary_path_with_template(wi_string_t *template) { |
|---|
| | 126 | char path[WI_PATH_SIZE]; |
|---|
| | 127 | |
|---|
| | 128 | strlcpy(path, wi_string_cstring(template), sizeof(path)); |
|---|
| | 129 | |
|---|
| | 130 | if(!mktemp(path)) |
|---|
| | 131 | return NULL; |
|---|
| | 132 | |
|---|
| | 133 | return wi_string_with_cstring(path); |
|---|