Skip to content

Commit

Permalink
Create create_dir.js
Browse files Browse the repository at this point in the history
  • Loading branch information
pacmano1 authored Mar 13, 2024
1 parent 630cb84 commit 354ce6b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions create_dir.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Creates a directory if it does not already exist.
*
* @param {String} dir - The path of the directory to create. Can be absolute or relative.
*
* This function attempts to create the directory specified by the `dir` parameter.
* It first checks if the directory already exists. If it does not, it tries to create the directory
* and all necessary parent directories. If the directory cannot be created, logs an error message.
*/
function create_dir(dir) {
var directory = new java.io.File(dir);
if (!directory.exists()) {
var created = directory.mkdirs();
if (!created) {
logger.error("Failed to create the directory.");
}
return;
}
}

0 comments on commit 354ce6b

Please sign in to comment.