sparsefile
This module implements sparse file
"hole punching" on GNU+Linux, Microsoft Windows, and probably Mac OS X (untested).
This allows you to quickly create sparse file gaps such that the gaps appear to be
filled with null (b"\0") bytes but they don't occupy any actual disk space.
This is a pure-Python module which uses ctypes/pywin32/fcntl to do its dirty work.
Dependencies
pywin32 on Windows. None otherwise.
Examples
First import the library and choose an appropriate victim.
>>> from pathlib import Path
>>> import sparsefile
>>> path = Path("my_file.bin")
Then sparsification comes in three different flavours:
-
sparsefile.ensure_sparse(path, offset=1000, length=3000)Make the byte range 1000-3999 (inclusive) sparse. If the OS or filesystem do not support the operation, raise a
SparsifyError. -
sparsefile.ensure_zeros_maybe_sparse(path, offset=1000, length=3000)Fill the byte range 1000-3999 (inclusive) with zeros. The byte range will also be sparse if the OS and filesystem support it. The function returns a boolean that indicates whether the byte range was successfully made sparse.
-
sparsefile.maybe_sparse(path, offset=1000, length=3000)Try to make the byte range 1000-3999 (inclusive) sparse. Do nothing if the OS or filesystem do not support it. If the file is currently shorter than 4000 bytes, then it will remain so.
Issues
- The test suite is severely lacking.
- Hasn't been tested on OS X (sorry).
Metadata
Release files for sparsefile 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sparsefile-0.1.0.tar.gz | 5.9 kB | Without provenance | Details for sparsefile-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sparsefile-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for sparsefile-0.1.0-py3-none-any.whl |
Total release size: 11.4 kB
Release files / sparsefile-0.1.0.tar.gz
| Download URL | sparsefile-0.1.0.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
78a0d8799f7f3f856813322daaa5705eb3536f5bc879f6b9c2e66d932178984a
|
|
BLAKE2b-256 checksum How to use checksums |
c31d9c23dfb8c19b94ed57042dfdaada34eaf361c1839bda665e36a0edc18154
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2
|
Release files / sparsefile-0.1.0-py3-none-any.whl
| Download URL | sparsefile-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1b953d6ffa95526d01e5c4005ed0e75030b7fd6d71cae8689bc0ab01ad10fb1f
|
|
BLAKE2b-256 checksum How to use checksums |
0930fdd86ee6249d269fbd523caed5457828673f8e596df6023af74552584f3e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2
|
Security for sparsefile 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.