You should do some work to make sure that `mode` is of the form you expect, that is, a string containing `Constants.MODE_FILE` or `Constants.MODE_DIRECTORY`.  Anything else should cause the callback to be called with an EINVAL error, indicating the mode is unknown/incorrect.