FIX the dolCopyDir fails if target dir does not exists.
This commit is contained in:
parent
4723eac227
commit
3fa19f84e3
@ -515,13 +515,23 @@ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists)
|
|||||||
|
|
||||||
$result=0;
|
$result=0;
|
||||||
|
|
||||||
dol_syslog("files.lib.php::dolCopyr srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." overwriteifexists=".$overwriteifexists);
|
dol_syslog("files.lib.php::dolCopyDir srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." overwriteifexists=".$overwriteifexists);
|
||||||
|
|
||||||
if (empty($srcfile) || empty($destfile)) return -1;
|
if (empty($srcfile) || empty($destfile)) return -1;
|
||||||
|
|
||||||
$destexists=dol_is_dir($destfile);
|
$destexists=dol_is_dir($destfile);
|
||||||
if (! $overwriteifexists && $destexists) return 0;
|
if (! $overwriteifexists && $destexists) return 0;
|
||||||
|
|
||||||
|
if (! $destexists)
|
||||||
|
{
|
||||||
|
// We must set mask just before creating dir, becaause it can be set differently by dol_copy
|
||||||
|
umask(0);
|
||||||
|
$dirmaskdec=octdec($newmask);
|
||||||
|
if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $dirmaskdec=octdec($conf->global->MAIN_UMASK);
|
||||||
|
$dirmaskdec |= octdec('0200'); // Set w bit required to be able to create content for recursive subdirs files
|
||||||
|
dol_mkdir($destfile."/".$file, '', decoct($dirmaskdec));
|
||||||
|
}
|
||||||
|
|
||||||
$srcfile=dol_osencode($srcfile);
|
$srcfile=dol_osencode($srcfile);
|
||||||
$destfile=dol_osencode($destfile);
|
$destfile=dol_osencode($destfile);
|
||||||
|
|
||||||
@ -538,6 +548,7 @@ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists)
|
|||||||
{
|
{
|
||||||
if (!is_dir($destfile."/".$file))
|
if (!is_dir($destfile."/".$file))
|
||||||
{
|
{
|
||||||
|
// We must set mask just before creating dir, becaause it can be set differently by dol_copy
|
||||||
umask(0);
|
umask(0);
|
||||||
$dirmaskdec=octdec($newmask);
|
$dirmaskdec=octdec($newmask);
|
||||||
if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $dirmaskdec=octdec($conf->global->MAIN_UMASK);
|
if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $dirmaskdec=octdec($conf->global->MAIN_UMASK);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user