Re: Copying Directory
| From: | Michael Virnstein | Date: | Mon, 08 Apr 2002 07:56:25 +0000 |
| Subject: | Re: Copying Directory | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-92000@lists.php.net to get a copy of this message | ||
there was a typo...this one should work
#########################################################
#
# boolean copy_dirs ( string src_dir, string target_dir )
#
#########################################################
# copy a directory with subdirectories to a target directory
#########################################################
# Function Parameters:
# string src_dir: source directory
# string target_dir: target directory
#########################################################
# Return Values:
# 0 - error while copying
# 1 - files copied successfully
#########################################################
function copy_dirs ( $src_dir, $target_dir ) {
$src_dir = ereg_replace ( "/$", "", $src_dir );
$target_dir = ereg_replace ( "/$", "", $target_dir );
if ( filetype ( $src_dir ) != "dir" ):
return (0);
endif;
if ( !file_exists ( $target_dir ) ):
mkdir ( $target_dir, 0777 );
endif;
$hdl = opendir ( $src_dir );
while ( ( $file = readdir ( $hdl ) ) !== false ):
if ( $file != "." && $file != ".." && $file !=
"" ):
if ( filetype ( $src_dir."/".$file) == "dir" ):
if ( !copy_dirs ( $src_dir."/".$file,
$target_dir."/".$file ) ):
return (0);
endif;
else:
if ( !copy ( $src_dir."/".$file, $target_dir."/".$file ) ):
return (0);
endif;
endif;
endwhile;
return (1);
}
> "Hiroshi Ayukawa" <ayu@e-fukuoka.co.jp> schrieb im Newsbeitrag
> news:7AC1DECF80B857.ayu@e-fukuoka.co.jp...
> > Hello,
> >
> > I guess anyone have made the function to coppy directories, not files.
> > I'd like to copy directory including sub directories to other place.
> > Doesn't anyone has mades that kind of function?And please telll me.
> >
> > Thamks in advance.
> > HiroshiAyukawa
> >
> > http://hoover.ktplan.ne.jp/kaihatsu/php_en/index.php?type=top
> >
>
>