Copy folder

From Biophp.net

Jump to: navigation, search

#-------------------------------------------------------------------------------
# Title     : copy_folder
# Usage     :
# Function  :
# Example   :
# Keywords  :
# Options   :
# Author    : swizec at swizec dot com
# Category  :
# Reference :
# Returns   :
# Version   : 20071225
#------------------------------------------------------------------------------
function copy_folder( $source, $target ){
        if ( is_dir( $source ) ){
            @mkdir( $target );
            $d = dir( $source );
            while ( FALSE !== ( $entry = $d->read() ) ) {
                if ( $entry == '.' || $entry == '..' ){
                    continue;
                }

                $Entry = $source . '/' . $entry;
                if ( is_dir( $Entry ) ){
                    full_copy( $Entry, $target . '/' . $entry );
                    continue;
                }
                copy( $Entry, $target . '/' . $entry );
            }

            $d->close();
        }else {
            copy( $source, $target );
        }
}

 








Personal tools