문제

사용할 때 mkdir() 재귀 깃발이 True로 설정된 상태에서 생성 된 모든 디렉토리는 지정된 CHMOD 또는 마지막 디렉토리를 얻습니까? 예를 들어:

mkdir('/doesnotExist1/doesnotExist2/doesnotExist3/', 0755, true);

새로 만든 디렉토리가 될 것입니다 /doesnotExist1/ 그리고 /doesnotExist1/doesnotExist2/ 또한 동일한 chmod를 얻으십시오 /doesnotExist1/doesnotExist2/doesnotExist3/ = 0755?

그렇지 않다면 어떤 방법이 있습니까? 위의 행동을 강요하십시오?

나는 이것을 직접 테스트 할 것이지만 *nix box atm에 액세스 할 수 없습니다.

도움이 되었습니까?

해결책

PHP 5.2.12로 Gentoo Linux에서 방금 테스트했습니다. 모두 동일한 권한이 있습니다.

soulmerge@shark-g:~$ php -a
Interactive shell

php > mkdir('asd/def/ghi', 0700, 1);
php > ^C
soulmerge@shark-g:~$ ls -hal asd
total 12K
drwx------  3 soulmerge soulmerge 4.0K 2010-01-12 10:32 .
drwxr-xr-x 79 soulmerge soulmerge 4.0K 2010-01-12 10:32 ..
drwx------  3 soulmerge soulmerge 4.0K 2010-01-12 10:32 def

다른 팁

mkdir ( 'localfilesystem', x, true)를 담당하는 C 함수는 main/streams/plain_wrapper.c의 php_plain_files_mkdir ()입니다. 그리고 그것은 전화합니다 php_mkdir(dir, mode TSRMLS_CC); "첫 번째"디렉토리의 경우 만들어야하며 VCWD_MKDIR(buf, (mode_t)mode)) 모든 하위 디렉터에 대해. php_mkdir ()는 약간의 안전 모드 확인을 수행 한 다음 호출합니다. VCWD_MKDIR예, 모드 매개 변수는 mkdir (p, x, true)에 의해 생성 된 모든 디렉토리에 사용됩니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top