Larry Brigman <[email protected]> writes:
> On Fri, Oct 1, 2010 at 7:02 PM, logical american
> <[email protected]> wrote:
>>
>>> What arguments are you passing to mkdir()? Do all elements of the path
>>> leading up to the new directory name exist? The following program works
>>> for me.
>>>
>>> #include<sys/stat.h>
>>> #include<sys/types.h>
>>> main() { mkdir("/tmp/foo bar-baz", 0777); }
>>
>> Try to make a directory with two depths, mkdir("/tmp/deeper/foo bar-baz
>> bam", 0777); and see if that fails. I have been playing around with the
>> directory depth and my program fails with two slash characters in the path.
dan...@krosp:~$ ls -ld '/tmp/foo bar'
ls: cannot access /tmp/foo bar: No such file or directory
dan...@krosp:~$ perl -e 'mkdir("/tmp/foo bar/baz quux", 0777) or die $!'
No such file or directory at -e line 1.
dan...@krosp:~$ mkdir /tmp/'foo bar'
dan...@krosp:~$ perl -e 'mkdir("/tmp/foo bar/baz quux", 0777) or die $!'
dan...@krosp:~$ ls -ld '/tmp/foo bar'{,/*}
drwxrwxr-x 3 daniel daniel 21 Oct 2 13:50 /tmp/foo bar
drwxrwxr-x 2 daniel daniel 6 Oct 2 13:50 /tmp/foo bar/baz quux
mkdir(2) and mkdir(3) (and related tools like mkdirat) will only create the
specific target directory, not any part of the path, as was mentioned.
Also, if that didn't work ... well, it would have been noticed. :)
> http://linux.die.net/man/3/mkdir mkdir() only takes two parameters and I'm
> not sure how it handles spaces in the parameter #1.
The same way any path handling function under Unix / POSIX does: they are
treated exactly the same as any other legal character for a file naming
component, which is to say like any character except for NUL and '/'.
Regards,
Daniel
--
✣ Daniel Pittman ✉ [email protected] ☎ +61 401 155 707
♽ made with 100 percent post-consumer electrons
_______________________________________________
PLUG mailing list
[email protected]
http://lists.pdxlinux.org/mailman/listinfo/plug