-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdirectoryCreate.js
More file actions
57 lines (48 loc) · 1.64 KB
/
directoryCreate.js
File metadata and controls
57 lines (48 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// ===================================================================
// Handler Function: createDirectory -p
// ===================================================================
// Import shared functions
const shared = require('sharedFunctions');
/**
* Creates a directory at the specified path, including parent directories if needed
* @param {Object} params - Command parameters
* @param {string} [params.dirPath] - Path to create (optional, defaults to documents path/.eof.mcpstudio)
* @returns {null|null} Returns null after setting tool result with directory creation status or error
*/
function createDirectory(params) {
var dirValidation = shared.validateDirectoryPath(
params.dirPath || MCPStudio.getDocumentsPath() + "/.eof.mcpstudio",
"dirPath"
);
var dirPath;
var success;
var result;
if (!dirValidation.ok) {
return shared.setErrorResult(dirValidation.message, {
operation: "createDirectory"
});
}
dirPath = dirValidation.value;
console.log("Create directory: " + dirPath);
// Create directory
if (!MCPStudio.fileExists(dirPath)) {
success = MCPStudio.createDirectory(dirPath);
if (!success) {
return shared.setErrorResult("Failed to create directory: " + dirPath, {
operation: "createDirectory",
path: dirPath
});
}
}
result = {
status: "Directory successfully created.",
path: dirPath
};
return shared.setSuccessResult(result, {
path: dirPath,
operation: "createDirectory"
});
}
module.exports = {
createDirectory
};