max filename size

Steve Purcell stephen_purcell at yahoo.com
Fri Mar 30 02:09:36 EST 2001


Voluciris wrote:
> Is there away to find the maximum filename length of the current os? On
> Windows it's 215 characters, but I don't want to hard code that in. It would
> be much more pythonic if it was portable.

I don't think there's a standard function for this.

On some platforms, the maximum filename length varies according to the
location on the disk. If you run UNIX with different filesystems mounted
in various locations on your directory tree, you might see the following
values for the maximum filename length in those locations:

    >>> import statvfs, os
    >>> os.statvfs('/')[statvfs.F_NAMEMAX]
    4032
    >>> os.statvfs('/boot')[statvfs.F_NAMEMAX]
    255

-Steve

-- 
Steve Purcell, Pythangelist
Get testing at http://pyunit.sourceforge.net/
Any opinions expressed herein are my own and not necessarily those of Yahoo




More information about the Python-list mailing list