We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement a new IO function in the HVM to give Bend the ability to create new directories in the file system.
create_directory(path, parents=False, exist_ok=False)
@spec create_directory(str, bool, bool) -> Result[None, Error]
Creates a new directory at the specified path.
path
parents
True
False
exist_ok
Returns Ok(None) if successful, or Err(reason) if an error occurs.
Ok(None)
Err(reason)
Possible (but not limited to) errors:
FileExists
FileNotFound
PermissionDenied
OSError
# Create a new directory result = create_directory("new_folder") # Ok(None)
# Create a directory with non-existent parents, creating them as needed result = create_directory("path/to/new/folder", parents=True) # Ok(None)
# Create a directory, allowing it to exist result = create_directory("maybe_existing_folder", exist_ok=True) # Ok(None)
# Try to create an existing directory result = create_directory("existing_folder") # Err(FileExists)
# Create a directory with non-existent parents result = create_directory("path/to/new/folder") # Err(FileNotFound)
The text was updated successfully, but these errors were encountered:
#420 add function to create directories
49c9662
imaqtkatt
No branches or pull requests
Implement a new IO function in the HVM to give Bend the ability to create new directories in the file system.
1.
create_directory(path, parents=False, exist_ok=False)
Creates a new directory at the specified path.
Parameters
path
: The path where the new directory should be createdparents
: IfTrue
, create parent directories as needed. IfFalse
, parent directories must existexist_ok
: IfTrue
, don't raise an error if the directory already existsReturns
Ok(None)
if successful, orErr(reason)
if an error occurs.Possible (but not limited to) errors:
FileExists
: The directory already exists andexist_ok
isFalse
FileNotFound
: A parent directory doesn't exist and parents isFalse
PermissionDenied
: The user doesn't have permission to create the directoryOSError
: Other OS-level errors (e.g., disk full, invalid path)Examples
Considerations
Test cases to implement
exist_ok
)parents
flag)The text was updated successfully, but these errors were encountered: