[python-win32] pure python way to open a file with write deny for others
Paul.Koning at dell.com
Paul.Koning at dell.com
Thu Mar 5 09:19:45 EST 2020
> 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
More information about the python-win32
mailing list