Changeset 4447

Show
Ignore:
Timestamp:
01/28/07 13:46:05 (2 years ago)
Author:
morris
Message:

Use mktemp() instead

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • libwired/trunk/libwired/file/wi-file.c

    r4442 r4447  
    123123#pragma mark - 
    124124 
    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; 
     125wi_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); 
    140134} 
    141135 
  • libwired/trunk/libwired/file/wi-file.h

    r4442 r4447  
    7070 
    7171 
    72 WI_EXPORT wi_string_t *                         wi_file_temporary_path_with_prefix(wi_string_t *); 
    73 WI_EXPORT wi_string_t *                         wi_file_temporary_path_with_prefix_in_directory(wi_string_t *, wi_string_t *); 
     72WI_EXPORT wi_string_t *                         wi_file_temporary_path_with_template(wi_string_t *); 
    7473 
    7574WI_EXPORT wi_boolean_t                          wi_file_delete(wi_string_t *);