docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10
Build a simple utility that creates and manages symbolic links in a filesystem for organizing related files.
Your task is to implement a file link manager that helps organize files by creating symbolic links. The manager should be able to create links to files, verify link creation, and handle various edge cases.
Implement a FileLinkManager class with the following functionality:
The manager should create symbolic links from a source path to a target path. When creating a link:
The manager should verify that a symbolic link exists and points to the expected target:
The manager should handle error conditions appropriately:
Your implementation should pass the following test cases:
/**
* Manages symbolic links in a filesystem
*/
class FileLinkManager {
/**
* Creates a new FileLinkManager
* @param {Object} fs - Filesystem module to use for operations
*/
constructor(fs);
/**
* Creates a symbolic link from linkPath to targetPath
* @param {string} targetPath - The path the symbolic link should point to
* @param {string} linkPath - The path where the symbolic link should be created
* @returns {boolean} - Returns true if link was created successfully
* @throws {Error} - Throws if link already exists or operation fails
*/
createLink(targetPath, linkPath);
/**
* Verifies if a path is a symbolic link and returns its target
* @param {string} linkPath - The path to check
* @returns {string|null} - Returns the target path if it's a symlink, null otherwise
*/
verifyLink(linkPath);
}
module.exports = { FileLinkManager };Provides an in-memory filesystem implementation for testing.