-
Notifications
You must be signed in to change notification settings - Fork 435
Open
Labels
enhancementNew feature or requestNew feature or request
Milestone
Description
Implement moving functionality to give Bend the ability to move files and directories. This should support both single file moving and recursive directory moving.
1. move(source, destination, overwrite=False)
@spec move(str, str, bool) -> Result[None, Error]Moves a file or directory from the source path to the destination path.
Parameters
source: Path of the file or directory to be moveddestination: Path where the file or directory should be moved tooverwrite: IfTrue, overwrites the destination if it exists. IfFalse, returns an error if the destination exists.
Returns Ok(None) if successful, or Err(reason) if an error occurs.
Possible (but not limited to) errors:
FileNotFound: The source file or directory does not existPermissionDenied: Lack of permission to read the source or write to the destinationFileExists: The destination already exists and overwrite isFalse
Examples
# Move a file
result = move("source.txt", "destination.txt")
# Ok(None)# Move and overwrite an existing file
result = move("source.txt", "destination.txt", overwrite=True)
# Ok(None)# Move a directory
result = move("source_dir", "dest_dir")
# Ok(None)# Try to move a non-existent file or directory
result = move("nonexistent", "dest")
# Err(FileNotFound)# Try to move to an existing destination without overwrite
result = move("source.txt", "existing.txt")
# Err(FileExists)Considerations
- Handle moving across different filesystems
- Consider preserving file metadata (e.g. permissions, timestamps) during moving.
- Handle moving directories with large numbers of files efficiently.
- Handle symbolic links appropriately (whether to follow them or move the link itself).
- Be aware of potential issues with moving files or directories that are currently in use.
- Implement proper error handling and propagation.
Test cases to implement
- Move a small text file
- Move a large binary file
- Move an empty directory
- Move a directory with multiple files and subdirectories
- Attempt to move a non-existent file or directory
- Attempt to move to a read-only destination
- Move a file or directory to an existing destination with and without overwrite flag
- Move a file or directory across different filesystems
- Move a file or directory with special characters in the name
- Move a symbolic link (both following and not following the link)
- Move files and directories with various permission settings
- Attempt to move a file or directory into itself or its subdirectory
- Move a file or directory that is currently open or in use
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request