Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

F_CREATED_QUERY

When you open a file for writing, it is created if it does not exist. The F_CREATED_QUERY fcntl operation determines whether it was in fact created, or an existing file was opened for writing.

This API is easy to test at a Python interactive session, a notebook, etc.:

>>> F_CREATED_QUERY = 1028
>>> import fcntl
>>> a = open("foo.txt", "w")
>>> fcntl.fcntl(a, F_CREATED_QUERY)
1
>>> a.close()
>>> b = open("foo.txt", "w")
>>> fcntl.fcntl(b, F_CREATED_QUERY)
0

See createdquery.py for a very small library wrapping this function, and createdquery_test.py for a test case, which you can run with python3 -m unittest createdquery_test.py.