Skip to content

Commit

Permalink
Add PHP file_exists (#461)
Browse files Browse the repository at this point in the history
* Add PHP file_exists

* Update src/php/filesystem/file_exists.js

---------

Co-authored-by: Kevin van Zonneveld <vanzonneveld@gmail.com>
  • Loading branch information
erikn69 and kvz committed Apr 5, 2024
1 parent 1d7f971 commit 6f1f4d2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions 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)
}
1 change: 1 addition & 0 deletions 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')

0 comments on commit 6f1f4d2

Please sign in to comment.