When you enable versioning for any file it will attache the versionable aspect to that file. so, if you want to find all such file you just need to fire a query to fetch all the files with versionable aspect applied. You can do it via javascript APIs or JAVA as well up to you.