forked from dortania/OpenCore-Legacy-Patcher
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into sequoia-development
- Loading branch information
Showing
13 changed files
with
228 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
""" | ||
volume: Volume utilities for macOS | ||
------------------------------------------------------------------------------- | ||
Usage - Checking if Copy on Write is supported between source and destination: | ||
>>> from volume import can_copy_on_write | ||
>>> source = "/path/to/source" | ||
>>> destination = "/path/to/destination" | ||
>>> can_copy_on_write(source, destination) | ||
True | ||
------------------------------------------------------------------------------- | ||
Usage - Generating copy arguments: | ||
>>> from volume import generate_copy_arguments | ||
>>> source = "/path/to/source" | ||
>>> destination = "/path/to/destination" | ||
>>> _command = generate_copy_arguments(source, destination) | ||
>>> _command | ||
['/bin/cp', '-c', '/path/to/source', '/path/to/destination'] | ||
------------------------------------------------------------------------------- | ||
Usage - Querying volume properties: | ||
>>> from volume import PathAttributes | ||
>>> path = "/path/to/file" | ||
>>> obj = PathAttributes(path) | ||
>>> obj.mount_point() | ||
"/" | ||
>>> obj.supports_clonefile() | ||
True | ||
""" | ||
|
||
from .properties import PathAttributes | ||
from .copy import can_copy_on_write, generate_copy_arguments |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
""" | ||
copy.py: Generate performant '/bin/cp' arguments for macOS | ||
""" | ||
|
||
from pathlib import Path | ||
|
||
from .properties import PathAttributes | ||
|
||
|
||
def can_copy_on_write(source: str, destination: str) -> bool: | ||
""" | ||
Check if Copy on Write is supported between source and destination | ||
""" | ||
source_obj = PathAttributes(source) | ||
return source_obj.mount_point() == PathAttributes(str(Path(destination).parent)).mount_point() and source_obj.supports_clonefile() | ||
|
||
|
||
def generate_copy_arguments(source: str, destination: str) -> list: | ||
""" | ||
Generate performant '/bin/cp' arguments for macOS | ||
""" | ||
_command = ["/bin/cp", source, destination] | ||
if not Path(source).exists(): | ||
raise FileNotFoundError(f"Source file not found: {source}") | ||
if not Path(destination).parent.exists(): | ||
raise FileNotFoundError(f"Destination directory not found: {destination}") | ||
|
||
# Check if Copy on Write is supported. | ||
if can_copy_on_write(source, destination): | ||
_command.insert(1, "-c") | ||
|
||
if Path(source).is_dir(): | ||
_command.insert(1, "-R") | ||
|
||
return _command |
Oops, something went wrong.