copy_dir [ WordPress Function ]
copy_dir ( $from, $to, $skip_list = array() )
| Parameters: |
|
| 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.
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 ]
Google Arama Sonuçlarý
- copy_dir | A HitchHackers guide through WordPress
Feb 11, 2011 ... function copy_dir($from, $to, $skip_list = array() ) { global $wp_filesystem; $dirlist = $wp_filesystem->dirlist($from); $from = trailingslashit($from) ...
hitchhackerguide.com - busybox/a2sd causes copy_dir PACKAGE:system SYSTEM: Problems - xda ...
OK, so I'm at my wits end trying to figure out what is wrong. Since I've added busybox and a2sd to my Hero rom, copy_dir PACKAGE:system ...
forum.xda-developers.com - Pull Request #27: Fix/Support relative path for copy_cache and ...
Apr 5, 2011 ... Error reported: `link': No such file or directory ###Fix copy_dir### Was only ... In addition, I changed the tmpdir method name by copy_dir which ...
github.com - 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