Feature #5974
Access PC_NAME_MAX and PC_PATH_MAX values
| Status: | Rejected | Start date: | 02/07/2012 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | - | % Done: | 0% |
|
| Category: | - | |||
| Target version: | - |
Description
Hi,
In order to construct file names that don't raise Errno::ENAMETOOLONG, I'd like to be able to access PC_NAME_MAX and PC_PATH_MAX from pathconf given a particular directory object.
I've attached a patch which exposes both of these values on a Dir object.
History
Updated by kosaki (Motohiro KOSAKI) 4 months ago
> Hi,
>
> In order to construct file names that don't raise Errno::ENAMETOOLONG, I'd like to be able to access PC_NAME_MAX and PC_PATH_MAX from pathconf given a particular directory object.
>
> I've attached a patch which exposes both of these values on a Dir object.
Hmm...
I don't think it's useful. why? fpatchconf() doesn't have an enough
portable and reliable meanings. example, fpathconf(PC_PATH_MAX) on
linux glibc always return PATH_MAX (=4096). but some linux filesystems
can only treat 256 bytes path length. Therefore, even if you properly
checked path length, you still might get
path length related error from syscalls.
I'm afraid this method bring rubyist a misunderstand.
Updated by tenderlovemaking (Aaron Patterson) 4 months ago
- Status changed from Open to Rejected
Ugh. I didn't know that is the behavior on linux. I agree this would cause confusion, so I will just close it. Thanks for reading!
Updated by naruse (Yui NARUSE) 4 months ago
The portable way to check the too long filename is just make a file and catch Errno::ENAMETOOLONG.
Unix has many related constants and functions but they are useless.