How to open a file exclusively?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to open a file exclusively?

wl2776
Administrator
My application writes files with video and audio data (MPEG2 Program Stream).
I need to open these files exclusively, that is so, that any other process cannot open these files until my application finishes writing and closes them.

These files are ordinary files, not special devices or protocols, like rtsp://, http://, etc.

How do I get the file descriptor from AVFormatContext in order to use flock()?

Or, is there any other way to lock files, created by libav?
Reply | Threaded
Open this post in threaded view
|

Re: How to open a file exclusively?

wl2776
Administrator
Found.
url_fileno(AVFormatContext->pb) returns URLContext *
URLContext->priv_data is the file descriptor, returned from open()