Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python os.fpathconf() method

Python os.fpathconf() method

Python File methods Python OS file/directory methods


Overview

The os.fpathconf() method returns system configuration information for an open file.

Available on Unix.

Syntax

The **fpathconf()** method syntax is as follows:



os.fpathconf(fd, name)

Parameters

Return Value

Returns system configuration information for an open file.

Example

The following example demonstrates the use of the fpathconf() method:



#!/usr/bin/python

# -*- coding: UTF-8 -*-



import os, sys



# Open file

fd = os.open( "foo.txt", os.O_RDWR|os.O_CREAT )



print "%s" % os.pathconf_names



# Get maximum file connections

no = os.fpathconf(fd, 'PC_LINK_MAX')

print "文件最大连接数为 :%d" % no



# Get maximum filename length

no = os.fpathconf(fd, 'PC_NAME_MAX')

print "文件名最大长度为 :%d" % no



# Close file

os.close( fd )



print "关闭文件成功!!"

The output of the above program is:



{'PC_MAX_INPUT': 2, 'PC_VDISABLE': 8, 'PC_SYNC_IO': 9, 

'PC_SOCK_MAXBUF': 12, 'PC_NAME_MAX': 3, 'PC_MAX_CANON': 1, 

'PC_PRIO_IO': 11, 'PC_CHOWN_RESTRICTED': 6, 'PC_ASYNC_IO': 10, 

'PC_NO_TRUNC': 7, 'PC_FILESIZEBITS': 13, 'PC_LINK_MAX': 0, 

'PC_PIPE_BUF': 5, 'PC_PATH_MAX': 4}



文件最大连接数为 :127

文件名最大长度为 :255

Closed the file successfully!!

Python File methods Python OS file/directory methods