[python-win32] pure python way to open a file with write deny for others

Robin Becker robin at reportlab.com
Thu Mar 5 10:36:31 EST 2020


On 05/03/2020 14:19, Paul.Koning at dell.com wrote:
> 
> 
>> On Mar 5, 2020, at 5:42 AM, Robin Becker <robin at reportlab.com> wrote:
>>
>>
>> [EXTERNAL EMAIL]
>> I want to be able to read a windows file which is being periodically written by another process. I created a small extension ...
>>
>> that seems to work, but I wonder if there's an easier pure python way to do this. Looking at the docs I see O_EXCL, but the _SH_DENY flags seem to be absent.
> 
> If the _fsopen function is present then you might try passing the numeric value of those flags.  If the real issue is the lack of a Python wrapper around _fsopen, look at the ctypes module.  That offers a simple way to wrap existing shared library (DLL) APIs to make them visible as Python functions, without the need to write your own extension modules.  The documentation for ctypes in the Python library manual is quite good, and includes Windows specific examples.
> 
> 	paul
> 

yes I thought about doing this when the app moves to python 3.x; I'm only using the deny write value so passing the 
integer could work.
-- 
Robin Becker


More information about the python-win32 mailing list