_copy_dir [ WordPress Function ]
_copy_dir ( $from, $to, $skip_list = array() )
| Parameters: |
|
| See: |
|
| Returns: |
|
| Defined at: |
|
Copies a directory from one location to another via the WordPress Filesystem Abstraction.
Assumes that WP_Filesystem() has already been called and setup.
This is a temporary function for the 3.1 -> 3.2 upgrade only and will be removed in 3.3
Source
<?php
function _copy_dir($from, $to, $skip_list = array() ) {
global $wp_filesystem;
$dirlist = $wp_filesystem->dirlist($from);
$from = trailingslashit($from);
$to = trailingslashit($to);
$skip_regex = '';
foreach ( (array)$skip_list as $key => $skip_file )
$skip_regex .= preg_quote($skip_file, '!') . '|';
if ( !empty($skip_regex) )
$skip_regex = '!(' . rtrim($skip_regex, '|') . ')$!i';
foreach ( (array) $dirlist as $filename => $fileinfo ) {
if ( !empty($skip_regex) )
if ( preg_match($skip_regex, $from . $filename) )
continue;
if ( 'f' == $fileinfo['type'] ) {
if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) {
// If copy failed, chmod file to 0644 and try again.
$wp_filesystem->chmod($to . $filename, 0644);
if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) )
return new WP_Error('copy_failed', __('Could not copy file.'), $to . $filename);
}
} elseif ( 'd' == $fileinfo['type'] ) {
if ( !$wp_filesystem->is_dir($to . $filename) ) {
if ( !$wp_filesystem->mkdir($to . $filename, FS_CHMOD_DIR) )
return new WP_Error('mkdir_failed', __('Could not create directory.'), $to . $filename);
}
$result = _copy_dir($from . $filename, $to . $filename, $skip_list);
if ( is_wp_error($result) )
return $result;
}
}
return true;
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- Copy Dir command?
Hi people I was hoping somebody could tell me what the copy directory command is...i have not used dos for so long i have forgot. Thanx ...
www.computing.net - Microsoft Windows XP - Winnt32
/copydir:{i386|ia64}\FolderName : Creates an additional folder within the folder in which the Windows XP files are installed. Folder_name refers to a folder that ...
www.microsoft.com - copydir(1) - Linux man page
copydir is equivalent to mirrordir -ck --no-erase-directories ... (although -c implies -k anyway), so copydir is very much like a rigorous version of cp(1) ...
linux.die.net - Copydir Task
Copydir. Deprecated. This task has been deprecated. Use the ...
ant.apache.org