Currently, MFiles.create claims that it both creates an MFile using the MFileProviders or by using MFileOS and also checks if the file exists. However, the existence check only applies in the case of the MFileOS and not for instance MFileS3 or MFileZip. Note that we now have a separate method for checking existence (MFile::exists).
This PR would remove checking for existence in the create function. I think this change makes the code nicer since the create wasn't really checking existence for all types of MFiles. It also avoids null checks when using create. It makes testing simpler, for instance, I want to make tests that use MFile.create to test something that doesn't necessarily require files to exist.
I do not believe this counts as a breaking change, though it does change the documented behavior of this function. I added a second variant createIfExisting that returns null if exists is false (old behavior for create when its a MFileOS). Can change the names if you prefer!
Description of Changes
Currently,
MFiles.create
claims that it both creates anMFile
using theMFileProviders
or by usingMFileOS
and also checks if the file exists. However, the existence check only applies in the case of theMFileOS
and not for instanceMFileS3
orMFileZip
. Note that we now have a separate method for checking existence (MFile::exists
).This PR would remove checking for existence in the
create
function. I think this change makes the code nicer since thecreate
wasn't really checking existence for all types ofMFiles
. It also avoids null checks when usingcreate
. It makes testing simpler, for instance, I want to make tests that useMFile.create
to test something that doesn't necessarily require files to exist.I do not believe this counts as a breaking change, though it does change the documented behavior of this function. I added a second variant
createIfExisting
that returns null ifexists
is false (old behavior forcreate
when its aMFileOS
). Can change the names if you prefer!PR Checklist