Easy Tutorial
❮ Python Os Stat_Float_Times Python Func Number Ceil ❯

Python3 os.fpathconf() Method

Python3 OS File/Directory Methods


Overview

The os.fpathconf() method is used to return system configuration information for an open file.

Available on Unix.

Syntax

The syntax for the fpathconf() method 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/python3

import os, sys

# Open a file
fd = os.open("foo.txt", os.O_RDWR|os.O_CREAT)

print("%s" % os.pathconf_names)

# Get the maximum number of file links
no = os.fpathconf(fd, 'PC_LINK_MAX')
print("Maximum number of file links is :%d" % no)

# Get the maximum file name length
no = os.fpathconf(fd, 'PC_NAME_MAX')
print("Maximum file name length is :%d" % no)

# Close the file
os.close(fd)

print("Closed the file successfully!!")

Executing the above program outputs:

{'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}

Maximum number of file links is :127
Maximum file name length is :255
Closed the file successfully!!

Python3 OS File/Directory Methods

❮ Python Os Stat_Float_Times Python Func Number Ceil ❯