Prom deleting directory when using recursive mkdir

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Php guru's,

At the moment I'm working on a class that makes handling files and
directories easier within my framework. For this I'm combining
standard php filesystem functies into my own functions.

One of these functions creates directories, recursively if needed.
However when testing this code I ran into a problem. I use php 5.2.8
and since php 5.0.0 you should be able to use mkdir recursively by
setting the third parameter to TRUE.

Using this however I ran into some strange things. I used the
following code to create 3 directories:


mkdir('test_dir2', 0777, FALSE);
mkdir('test_dir3', 0777, TRUE);
mkdir('test_dir4/blaat', 0777, TRUE);


When I run this script and then open my ftp program I can delete
test_dir2 and test_dir3. However I can not delete test_dir4, not even
when I try deleting "blaat" first (which I can not remove as well).

I get the following error in my ftp program:
[23:25:38] 550 blaat: Permission denied (or in the case of the other
directory: test_dir4: permission denied)

In the end I can remove the directories one-by-one using rmdir(),
however I do want to be able to delete directories using ftp.

I used the function stat() to check some informatie about both
directories, information on both directories was nearly the same (dir2
and dir4). The only two differences were:
- test_dir2 has a different inode, but this is what you'd expect
- test_dir2 has 2 links (nlink => 2) where test_dir4 has 3 links
(nlink => 3) (Is this what you'd expect?)

Am I the only on with this problem or does it occur with others as

In the last case it might look like a bug in php.

Is there anybody who can tell me a bit more about this, or wouldn't
mind testing it himself?


PS: one more small question about scopes: can I use a php function
name such as fopen() in my own class since it is not in the top-level
scope anymore?

Re: Prom deleting directory when using recursive mkdir

Yorian escribió:
Quoted text here. Click to load it

Since you call it using Foo::fopen() or $foo->fopen() there is no chance
for conflicts.

BTW, it seems that in PHP 5.3 you'll be able define a regular function
called fopen() thanks to namespaces.

-- - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web:
-- Mi web de humor al baño María:

Site Timeline