I have been adding growing file support to my application which I am testing under Windows.
I have come across a small problem and I wondered whether the fix should be in the
library or in my user code.
If I start an instance of, say, bmxtranswrap writing an XMF file and then, start an
instance of mxf2raw (with the --gf flag) reading that same file then mxf2raw fails with a
could not open file message.
The problem seems to be that mxf2raw calls MXFFileReader::Open this in turn calls
AppMXFFileFactory::OpenRead which calls mxf_win32_file_open_read. Finally this calls:-
Because the file is opened with GENERIC_READ and FILE_SHARE_READ flags this seems to cause the
open failure.
If these flags are changed to GENERIC_READ and FILE_SHARE_READ | FILE_SHARE_WRITE
then mxf2raw is able to open the file whilst it is being written.
If you don't think this fix is appropriate then I could use the MODIFY_MODE file open
by adding some user code which would achieve the same thing although the open mode
would not strictly speaking be correct (due to an extra GENERIC_WRITE flag).
Many Thanks in advance
Steve
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I think you're right, the file should be opened with FILE_SHARE_READ | FILE_SHARE_WRITE sharing flag to allow reading whilst writing. This is confirmed by the table included in Creating and Opening Files. I'll make that change.
I remember working on this a couple years ago to support growing file import into Adobe Premiere Pro. Unfortunately they were opening files on their side in such a way that no combination of flags on bmx/libMXF's side could make it work.
Philip
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi
I have been adding growing file support to my application which I am testing under Windows.
I have come across a small problem and I wondered whether the fix should be in the
library or in my user code.
If I start an instance of, say, bmxtranswrap writing an XMF file and then, start an
instance of mxf2raw (with the --gf flag) reading that same file then mxf2raw fails with a
could not open file message.
The problem seems to be that mxf2raw calls MXFFileReader::Open this in turn calls
AppMXFFileFactory::OpenRead which calls mxf_win32_file_open_read. Finally this calls:-
mxf_win32_file_open(filename, flags, READ_MODE, mxfFile);
For READ_MODE this calls:-
newDiskFile->file = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, attrs_and_flags, NULL);
Because the file is opened with GENERIC_READ and FILE_SHARE_READ flags this seems to cause the
open failure.
If these flags are changed to GENERIC_READ and FILE_SHARE_READ | FILE_SHARE_WRITE
then mxf2raw is able to open the file whilst it is being written.
If you don't think this fix is appropriate then I could use the MODIFY_MODE file open
by adding some user code which would achieve the same thing although the open mode
would not strictly speaking be correct (due to an extra GENERIC_WRITE flag).
Many Thanks in advance
Steve
I think you're right, the file should be opened with FILE_SHARE_READ | FILE_SHARE_WRITE sharing flag to allow reading whilst writing. This is confirmed by the table included in Creating and Opening Files. I'll make that change.
I remember working on this a couple years ago to support growing file import into Adobe Premiere Pro. Unfortunately they were opening files on their side in such a way that no combination of flags on bmx/libMXF's side could make it work.
Philip