diff --git a/src/php/filesystem/file_exists.js b/src/php/filesystem/file_exists.js new file mode 100644 index 0000000000..00bbe64f37 --- /dev/null +++ b/src/php/filesystem/file_exists.js @@ -0,0 +1,11 @@ +module.exports = function file_exists(filename) { + // discuss at: https://locutus.io/php/file_exists/ + // original by: Erik Niebla + // note 1: so this function is Node-only + // example 1: file_exists('test/never-change.txt') + // returns 1: true + + const fs = require('fs') + + return fs.existsSync(filename) +} diff --git a/src/php/filesystem/index.js b/src/php/filesystem/index.js index d70d22615b..71686ed7f5 100644 --- a/src/php/filesystem/index.js +++ b/src/php/filesystem/index.js @@ -1,5 +1,6 @@ module.exports.basename = require('./basename') module.exports.dirname = require('./dirname') +module.exports.file_exists = require('./file_exists') module.exports.file_get_contents = require('./file_get_contents') module.exports.pathinfo = require('./pathinfo') module.exports.realpath = require('./realpath')