How to restrict file access based on file path under private directory? I have a list of files under  sites/default/files/private/abcde/manuals/.

I want to add restriction to the files based on certain logic which I can add in the code in a hook.
The logic would be based on a parameter set in by the admin.
So if the value  set to allow in the admin settings form , I would like to give access to view or download files under 'sites/default/files/private/abcde/manuals/' else would like to prevent user from accessing it.
Requests to files in the private file directory are routed through Drupal and access logic for these requests can be added by implementing hook_file_download.
The only argument to that hook implementation is $uri, which is the URI to the file. Using string comparison to see if you want to act upon this request should get you what you need.

Quoting the docs:


  If the user does not have permission to access the file, return -1. If the user has permission, return an array with the appropriate headers. If the file is not controlled by the current module, the return value should be NULL.