Changeset 31936 for trunk/src/wp-admin/includes/file.php
- Timestamp:
- 03/31/2015 02:10:06 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/file.php
r31884 r31936 142 142 * @return string a writable filename 143 143 */ 144 function wp_tempnam( $filename = '', $dir = '') {145 if ( empty( $dir) )144 function wp_tempnam( $filename = '', $dir = '' ) { 145 if ( empty( $dir ) ) { 146 146 $dir = get_temp_dir(); 147 $filename = basename($filename); 148 if ( empty($filename) ) 147 } 148 149 if ( empty( $filename ) || '.' == $filename ) { 149 150 $filename = time(); 150 151 $filename = preg_replace('|\..*$|', '.tmp', $filename); 152 $filename = $dir . wp_unique_filename($dir, $filename); 153 touch($filename); 154 return $filename; 151 } 152 153 // Use the basename of the given file without the extension as the name for the temporary directory 154 $temp_filename = basename( $filename ); 155 $temp_filename = preg_replace( '|\.[^.]*$|', '', $temp_filename ); 156 157 // If the folder is falsey, use it's parent directory name instead 158 if ( ! $temp_filename ) { 159 return wp_tempnam( dirname( $filename ), $dir ); 160 } 161 162 $temp_filename .= '.tmp'; 163 $temp_filename = $dir . wp_unique_filename( $dir, $temp_filename ); 164 touch( $temp_filename ); 165 166 return $temp_filename; 155 167 } 156 168 … … 628 640 // Create those directories if need be: 629 641 foreach ( $needed_dirs as $_dir ) { 630 if ( ! $wp_filesystem->mkdir($_dir, FS_CHMOD_DIR) && ! $wp_filesystem->is_dir($_dir) ) // Only check to see if the Dir exists upon creation failure. Less I/O this way. 642 // Only check to see if the Dir exists upon creation failure. Less I/O this way. 643 if ( ! $wp_filesystem->mkdir( $_dir, FS_CHMOD_DIR ) && ! $wp_filesystem->is_dir( $_dir ) ) { 631 644 return new WP_Error( 'mkdir_failed_ziparchive', __( 'Could not create directory.' ), substr( $_dir, strlen( $to ) ) ); 645 } 632 646 } 633 647 unset($needed_dirs);
Note: See TracChangeset
for help on using the changeset viewer.