././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1693045909.1944022 reflink-0.2.2/0000755000175000017500000000000014472352225012261 5ustar00rsmetrsmet././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1501169719.0 reflink-0.2.2/AUTHORS.rst0000644000175000017500000000023113136404067014132 0ustar00rsmetrsmet======= Credits ======= Development Lead ---------------- * Ruben De Smet Contributors ------------ None yet. Why not be the first? ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1501170083.0 reflink-0.2.2/CONTRIBUTING.rst0000644000175000017500000000623713136404643014730 0ustar00rsmetrsmet.. highlight:: shell ============ Contributing ============ Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given. You can contribute in many ways: Types of Contributions ---------------------- Report Bugs ~~~~~~~~~~~ Report bugs at https://gitlab.com/rubdos/pyreflink/issues. If you are reporting a bug, please include: * Your operating system name and version. * Any details about your local setup that might be helpful in troubleshooting. * Detailed steps to reproduce the bug. Fix Bugs ~~~~~~~~ Look through the GitHub issues for bugs. Anything tagged with "bug" and "help wanted" is open to whoever wants to implement it. Implement Features ~~~~~~~~~~~~~~~~~~ Look through the GitHub issues for features. Anything tagged with "enhancement" and "help wanted" is open to whoever wants to implement it. Write Documentation ~~~~~~~~~~~~~~~~~~~ Python reflink could always use more documentation, whether as part of the official Python reflink docs, in docstrings, or even on the web in blog posts, articles, and such. Submit Feedback ~~~~~~~~~~~~~~~ The best way to send feedback is to file an issue at https://gitlab.com/rubdos/pyreflink/issues. If you are proposing a feature: * Explain in detail how it would work. * Keep the scope as narrow as possible, to make it easier to implement. * Remember that this is a volunteer-driven project, and that contributions are welcome :) Get Started! ------------ Ready to contribute? Here's how to set up `reflink` for local development. 1. Fork the `reflink` repo on GitHub. 2. Clone your fork locally:: $ git clone git@github.com:your_name_here/reflink.git 3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:: $ mkvirtualenv reflink $ cd reflink/ $ python setup.py develop 4. Create a branch for local development:: $ git checkout -b name-of-your-bugfix-or-feature Now you can make your changes locally. 5. When you're done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:: $ flake8 reflink tests $ python setup.py test or py.test $ tox To get flake8 and tox, just pip install them into your virtualenv. 6. Commit your changes and push your branch to GitHub:: $ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature 7. Submit a pull request through the GitHub website. Pull Request Guidelines ----------------------- Before you submit a pull request, check that it meets these guidelines: 1. The pull request should include tests. 2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst. 3. The pull request should work for Python 2.6, 2.7, 3.3, 3.4 and 3.5, and for PyPy. Check https://travis-ci.org/rubdos/reflink/pull_requests and make sure that the tests pass for all supported Python versions. Tips ---- To run a subset of tests:: $ py.test tests.test_reflink ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1520582771.0 reflink-0.2.2/HISTORY.rst0000644000175000017500000000066113250440163014147 0ustar00rsmetrsmet======= History ======= 0.2.0 (2018-03-09) ------------------ New features: * APFS/Darwin support * Filenames outside ascii are supported (thank you, Kriskras99) Bug fixes: * Building on newer glibc (thank you, Frankie Dintino) * Better error handling for ENOENT Other changes: * Continuous integration for Windows (AppVeyor), integrated in the GitLab pipeline 0.1.0 (2017-07-27) ------------------ * First release on PyPI. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1501169719.0 reflink-0.2.2/LICENSE0000644000175000017500000000206113136404067013263 0ustar00rsmetrsmet MIT License Copyright (c) 2017, Ruben De Smet Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1501315910.0 reflink-0.2.2/MANIFEST.in0000644000175000017500000000045013137041506014010 0ustar00rsmetrsmetinclude AUTHORS.rst include CONTRIBUTING.rst include HISTORY.rst include LICENSE include README.rst recursive-include tests * recursive-include reflink *.c *.h recursive-exclude * __pycache__ recursive-exclude * *.py[co] recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1693045909.1954024 reflink-0.2.2/PKG-INFO0000644000175000017500000000730014472352225013356 0ustar00rsmetrsmetMetadata-Version: 2.1 Name: reflink Version: 0.2.2 Summary: Python reflink wraps around platform specific reflink implementations Home-page: https://gitlab.com/rubdos/pyreflink Author: Ruben De Smet Author-email: pypi@rubdos.be License: MIT license Keywords: reflink Classifier: Development Status :: 2 - Pre-Alpha Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License Classifier: Natural Language :: English Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 License-File: LICENSE License-File: AUTHORS.rst ============== Python reflink ============== .. image:: https://img.shields.io/pypi/v/reflink.svg :target: https://pypi.python.org/pypi/reflink .. image:: https://gitlab.com/rubdos/pyreflink/badges/master/build.svg :target: https://gitlab.com/rubdos/pyreflink/pipelines .. image:: https://ci.appveyor.com/api/projects/status/ta2rn0irw52ua5sw?svg=true :target: https://ci.appveyor.com/project/RubenDeSmet/pyreflink :alt: Windows build status .. image:: https://readthedocs.org/projects/reflink/badge/?version=latest :target: https://reflink.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status .. image:: https://readthedocs.org/projects/reflink/badge/?version=latest :target: https://rubdos.gitlab.io/pyreflink/docs :alt: Documentation Status .. image:: https://gitlab.com/rubdos/pyreflink/badges/master/coverage.svg :target: https://rubdos.gitlab.io/pyreflink/coverage :alt: Coverage report Python wrapper around the ``reflink`` system calls. Note: Python is implementing this natively upstream, cfr. https://bugs.python.org/issue37157. * Free software: MIT license * Documentation: https://reflink.readthedocs.io. * Documentation for master branch: https://rubdos.gitlab.io/pyreflink/docs Features -------- * Btrfs, XFS, OCFS2 ``reflink`` support. Btrfs is tested the most. * Apple macOS APFS ``clonefile`` support. Little testing, be careful. It might eat data. * A convenience method that checks support for reflinks within a specific directory. Installation ------------ This library is available on `pypi`_:: pip install reflink Quick start example ------------------- To use Python reflink in a project:: from reflink import reflink # Reflink copy 'large_file.img' to 'copy_of_file.img' reflink("large_file.img", "copy_of_file.img") Help wanted ----------- Someone to implement a `Windows/ReFS implementation `__ Support _______ Support on `the GitLab repository `__, feel free to file an issue. Credits --------- This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template. .. _Cookiecutter: https://github.com/audreyr/cookiecutter .. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage .. _pypi: https://pypi.python.org/pypi/reflink ======= History ======= 0.2.0 (2018-03-09) ------------------ New features: * APFS/Darwin support * Filenames outside ascii are supported (thank you, Kriskras99) Bug fixes: * Building on newer glibc (thank you, Frankie Dintino) * Better error handling for ENOENT Other changes: * Continuous integration for Windows (AppVeyor), integrated in the GitLab pipeline 0.1.0 (2017-07-27) ------------------ * First release on PyPI. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1595432589.0 reflink-0.2.2/README.rst0000644000175000017500000000461613706057215013757 0ustar00rsmetrsmet============== Python reflink ============== .. image:: https://img.shields.io/pypi/v/reflink.svg :target: https://pypi.python.org/pypi/reflink .. image:: https://gitlab.com/rubdos/pyreflink/badges/master/build.svg :target: https://gitlab.com/rubdos/pyreflink/pipelines .. image:: https://ci.appveyor.com/api/projects/status/ta2rn0irw52ua5sw?svg=true :target: https://ci.appveyor.com/project/RubenDeSmet/pyreflink :alt: Windows build status .. image:: https://readthedocs.org/projects/reflink/badge/?version=latest :target: https://reflink.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status .. image:: https://readthedocs.org/projects/reflink/badge/?version=latest :target: https://rubdos.gitlab.io/pyreflink/docs :alt: Documentation Status .. image:: https://gitlab.com/rubdos/pyreflink/badges/master/coverage.svg :target: https://rubdos.gitlab.io/pyreflink/coverage :alt: Coverage report Python wrapper around the ``reflink`` system calls. Note: Python is implementing this natively upstream, cfr. https://bugs.python.org/issue37157. * Free software: MIT license * Documentation: https://reflink.readthedocs.io. * Documentation for master branch: https://rubdos.gitlab.io/pyreflink/docs Features -------- * Btrfs, XFS, OCFS2 ``reflink`` support. Btrfs is tested the most. * Apple macOS APFS ``clonefile`` support. Little testing, be careful. It might eat data. * A convenience method that checks support for reflinks within a specific directory. Installation ------------ This library is available on `pypi`_:: pip install reflink Quick start example ------------------- To use Python reflink in a project:: from reflink import reflink # Reflink copy 'large_file.img' to 'copy_of_file.img' reflink("large_file.img", "copy_of_file.img") Help wanted ----------- Someone to implement a `Windows/ReFS implementation `__ Support _______ Support on `the GitLab repository `__, feel free to file an issue. Credits --------- This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template. .. _Cookiecutter: https://github.com/audreyr/cookiecutter .. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage .. _pypi: https://pypi.python.org/pypi/reflink ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1693045909.1894023 reflink-0.2.2/docs/0000755000175000017500000000000014472352225013211 5ustar00rsmetrsmet././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1501415892.0 reflink-0.2.2/docs/Makefile0000644000175000017500000001520313137344724014654 0ustar00rsmetrsmet# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = -T -E -D language=en SPHINXBUILD = sphinx-build PAPER = BUILDDIR = _build # User-friendly check for sphinx-build ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) endif # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . # the i18n builder cannot share the environment and doctrees with the others I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " singlehtml to make a single large HTML file" @echo " pickle to make pickle files" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " qthelp to make HTML files and a qthelp project" @echo " devhelp to make HTML files and a Devhelp project" @echo " epub to make an epub" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " latexpdf to make LaTeX files and run them through pdflatex" @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" @echo " text to make text files" @echo " man to make manual pages" @echo " texinfo to make Texinfo files" @echo " info to make Texinfo files and run them through makeinfo" @echo " gettext to make PO message catalogs" @echo " changes to make an overview of all changed/added/deprecated items" @echo " xml to make Docutils-native XML files" @echo " pseudoxml to make pseudoxml-XML files for display purposes" @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" clean: rm -rf $(BUILDDIR)/* html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." singlehtml: $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml @echo @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." qthelp: $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/reflink.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/reflink.qhc" devhelp: $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp @echo @echo "Build finished." @echo "To view the help file:" @echo "# mkdir -p $$HOME/.local/share/devhelp/reflink" @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/reflink" @echo "# devhelp" epub: $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub @echo @echo "Build finished. The epub file is in $(BUILDDIR)/epub." latex: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Run \`make' in that directory to run these through (pdf)latex" \ "(use \`make latexpdf' here to do that automatically)." latexpdf: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through pdflatex..." $(MAKE) -C $(BUILDDIR)/latex all-pdf @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." latexpdfja: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through platex and dvipdfmx..." $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." text: $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text @echo @echo "Build finished. The text files are in $(BUILDDIR)/text." man: $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man @echo @echo "Build finished. The manual pages are in $(BUILDDIR)/man." texinfo: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." @echo "Run \`make' in that directory to run these through makeinfo" \ "(use \`make info' here to do that automatically)." info: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo "Running Texinfo files through makeinfo..." make -C $(BUILDDIR)/texinfo info @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." gettext: $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale @echo @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." linkcheck: $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." xml: $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml @echo @echo "Build finished. The XML files are in $(BUILDDIR)/xml." pseudoxml: $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml @echo @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1693045909.1834023 reflink-0.2.2/docs/_build/0000755000175000017500000000000014472352225014447 5ustar00rsmetrsmet././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1693045909.1834023 reflink-0.2.2/docs/_build/html/0000755000175000017500000000000014472352225015413 5ustar00rsmetrsmet././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1693045909.1914022 reflink-0.2.2/docs/_build/html/_static/0000755000175000017500000000000014472352225017041 5ustar00rsmetrsmet././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1501412808.0 reflink-0.2.2/docs/_build/html/_static/ajax-loader.gif0000644000175000017500000000124113137336710021713 0ustar00rsmetrsmetGIF89aU|NU|l!Created with ajaxload.info! ! NETSCAPE2.0,30Ikc:Nf E1º.`q-[9ݦ9 JkH! ,4N!  DqBQT`1 `LE[|ua C%$*! ,62#+AȐ̔V/cNIBap ̳ƨ+Y2d! ,3b%+2V_ ! 1DaFbR]=08,Ȥr9L! ,2r'+JdL &v`\bThYB)@<&,ȤR! ,3 9tڞ0!.BW1  sa50 m)J! ,2 ٜU]qp`a4AF0` @1Α! ,20IeBԜ) q10ʰPaVڥ ub[;././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1501412808.0 reflink-0.2.2/docs/_build/html/_static/comment-bright.png0000644000175000017500000000136413137336710022470 0ustar00rsmetrsmetPNG  IHDRaIDATx<ߙm۶m۶qm۶m۶mM=D8tٍ\{56j>Qn~3sD{oS+ٻ؀=nnW?XumAHI%pHscYoo_{Z)48sڳۗ8YüYsj34s^#ǒtˋqkZܜwݿߵ>!8pVn{շ=n$p\^;=;wPIENDB`././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1501412808.0 reflink-0.2.2/docs/_build/html/_static/comment-close.png0000644000175000017500000000147513137336710022321 0ustar00rsmetrsmetPNG  IHDRaIDATxm8$km۶m۶m۶m۶AMfp:O'e$Qq aO[B3U9Og+ł-81dw=7q1CKa~ ʏ lϕ]O4l!A@@wny^xa*;1uSWݦO<*7g>b~yޞ mN\(t:+tU&>9Z}Ok=wԈ=ehjo OSd̳m#(2ڮ&!Q&$|~\>&nMK<+W 7zɫ ?w!8_O ާ4& MS'/қ=rּ`V0!?t'$#'P`iawP?Dãqف.`Ž lZ%9A {EҺ !;e`fT]P]ZCDX2e)ןryOZs߂Ј {1<*Bx `(B42|k@=PAȚe; HͭU`B@(IϚR F"a(. |R*wZB/bZ fMQ+d!!065.9Eq+@3ىVSËd8;&KpHh0f;hY,]|Lcne!fKcJFiySOhמ%ws vaJ{ڣ;/S3 ?qcC\qHxsemk2n&;4i$n3> ycdIENDB`././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1501412808.0 reflink-0.2.2/docs/_build/html/_static/file.png0000644000175000017500000000043613137336710020467 0ustar00rsmetrsmetPNG  IHDRaIDATxR){l ۶f=@ :3~箄rX$AX-D ~ lj(P%8<<9:: PO&$ l~X&EW^4wQ}^ͣ i0/H/@F)Dzq+j[SU5h/oY G&Lfs|{3%U+S`AFIENDB`././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1501412808.0 reflink-0.2.2/docs/_build/html/_static/minus.png0000644000175000017500000000013213137336710020674 0ustar00rsmetrsmetPNG  IHDR (!IDATxc8 g>@;(!&]f2nNIENDB`././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1501412808.0 reflink-0.2.2/docs/_build/html/_static/plus.png0000644000175000017500000000013213137336710020524 0ustar00rsmetrsmetPNG  IHDR (!IDATxc8 g>@;([[U @l-!a@IENDB`././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1501412808.0 reflink-0.2.2/docs/_build/html/_static/up-pressed.png0000644000175000017500000000032613137336710021635 0ustar00rsmetrsmetPNG  IHDRaIDATxc o+ Sb)SbG&W +H,Cق n;"VsT?.#&ھjFcgb ..NG`49l* Ŀ'q< *]Jcyjؖf b0Sԙµ|IENDB`././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1501412808.0 reflink-0.2.2/docs/_build/html/_static/up.png0000644000175000017500000000031313137336710020166 0ustar00rsmetrsmetPNG  IHDR7IDATx@ez $& 8:& :Kpwn}O<:!!{G@Dz?"̧ S{g<ݢ lMQwy|? 0 pq8q` pL-'SBNAwTń|U VIENDB`././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1501169719.0 reflink-0.2.2/docs/authors.rst0000644000175000017500000000003413136404067015423 0ustar00rsmetrsmet.. include:: ../AUTHORS.rst ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1501416128.0 reflink-0.2.2/docs/conf.py0000755000175000017500000001066613137345300014515 0ustar00rsmetrsmet#!/usr/bin/env python # -*- coding: utf-8 -*- # # reflink documentation build configuration file, created by # sphinx-quickstart on Tue Jul 9 22:26:36 2013. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys import os # Get the project root dir, which is the parent dir of this cwd = os.getcwd() project_root = os.path.dirname(cwd) # Insert the project root dir as the first element in the PYTHONPATH. # This lets us ensure that the source package is imported, and that its # version is used. sys.path.insert(0, project_root) # -- General configuration --------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The master toctree document. master_doc = 'index' # General information about the project. project = u'Python reflink' copyright = u"2017, Ruben De Smet" # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build'] # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # -- Options for HTML output ------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'default' # Add any paths that contain custom static files (such as style sheets) # here, relative to this directory. They are copied after the builtin # static files, so a file named "default.css" will overwrite the builtin # "default.css". html_static_path = ['_static'] # Output file base name for HTML help builder. htmlhelp_basename = 'reflinkdoc' # -- Options for LaTeX output ------------------------------------------ latex_elements = { # The paper size ('letterpaper' or 'a4paper'). #'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). #'pointsize': '10pt', # Additional stuff for the LaTeX preamble. #'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass # [howto/manual]). latex_documents = [ ('index', 'reflink.tex', u'Python reflink Documentation', u'Ruben De Smet', 'manual'), ] # The name of an image file (relative to this directory) to place at # the top of the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings # are parts, not chapters. #latex_use_parts = False # If true, show page references after internal links. #latex_show_pagerefs = False # If true, show URL addresses after external links. #latex_show_urls = False # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_domain_indices = True # -- Options for manual page output ------------------------------------ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ ('index', 'reflink', u'Python reflink Documentation', [u'Ruben De Smet'], 1) ] # If true, show URL addresses after external links. #man_show_urls = False # -- Options for Texinfo output ---------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ ('index', 'reflink', u'Python reflink Documentation', u'Ruben De Smet', 'reflink', 'One line description of project.', 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. #texinfo_appendices = [] # If false, no module index is generated. #texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. #texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. #texinfo_no_detailmenu = False autodoc_mock_imports = ['reflink.backend', 'reflink._backend', 'reflink.linux'] ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1501169719.0 reflink-0.2.2/docs/contributing.rst0000644000175000017500000000004113136404067016443 0ustar00rsmetrsmet.. include:: ../CONTRIBUTING.rst ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1501169719.0 reflink-0.2.2/docs/history.rst0000644000175000017500000000003413136404067015437 0ustar00rsmetrsmet.. include:: ../HISTORY.rst ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1501419872.0 reflink-0.2.2/docs/index.rst0000644000175000017500000000101013137354540015041 0ustar00rsmetrsmetWelcome to Python reflink's documentation! ====================================== Contents: .. toctree:: :maxdepth: 2 readme installation usage modules contributing authors history Quick start example ------------------- To use Python reflink in a project:: from reflink import reflink # Reflink copy 'large_file.img' to 'copy_of_file.img' reflink("large_file.img", "copy_of_file.img") Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1501170083.0 reflink-0.2.2/docs/installation.rst0000644000175000017500000000216013136404643016441 0ustar00rsmetrsmet.. highlight:: shell ============ Installation ============ Stable release -------------- To install Python reflink, run this command in your terminal: .. code-block:: console $ pip install reflink This is the preferred method to install Python reflink, as it will always install the most recent stable release. If you don't have `pip`_ installed, this `Python installation guide`_ can guide you through the process. .. _pip: https://pip.pypa.io .. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/ From sources ------------ The sources for Python reflink can be downloaded from the `Github repo`_. You can either clone the public repository: .. code-block:: console $ git clone git://gitlab.com/rubdos/pyreflink Or download the `tarball`_: .. code-block:: console $ curl -OL https://gitlab.com/rubdos/pyreflink/tarball/master Once you have a copy of the source, you can install it with: .. code-block:: console $ python setup.py install .. _Github repo: https://gitlab.com/rubdos/pyreflink .. _tarball: https://gitlab.com/rubdos/pyreflink/tarball/master ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1501169719.0 reflink-0.2.2/docs/make.bat0000644000175000017500000001447513136404067014627 0ustar00rsmetrsmet@ECHO OFF REM Command file for Sphinx documentation if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=sphinx-build ) set BUILDDIR=_build set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . set I18NSPHINXOPTS=%SPHINXOPTS% . if NOT "%PAPER%" == "" ( set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% ) if "%1" == "" goto help if "%1" == "help" ( :help echo.Please use `make ^` where ^ is one of echo. html to make standalone HTML files echo. dirhtml to make HTML files named index.html in directories echo. singlehtml to make a single large HTML file echo. pickle to make pickle files echo. json to make JSON files echo. htmlhelp to make HTML files and a HTML help project echo. qthelp to make HTML files and a qthelp project echo. devhelp to make HTML files and a Devhelp project echo. epub to make an epub echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter echo. text to make text files echo. man to make manual pages echo. texinfo to make Texinfo files echo. gettext to make PO message catalogs echo. changes to make an overview over all changed/added/deprecated items echo. xml to make Docutils-native XML files echo. pseudoxml to make pseudoxml-XML files for display purposes echo. linkcheck to check all external links for integrity echo. doctest to run all doctests embedded in the documentation if enabled goto end ) if "%1" == "clean" ( for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i del /q /s %BUILDDIR%\* goto end ) %SPHINXBUILD% 2> nul if errorlevel 9009 ( echo. echo.The 'sphinx-build' command was not found. Make sure you have Sphinx echo.installed, then set the SPHINXBUILD environment variable to point echo.to the full path of the 'sphinx-build' executable. Alternatively you echo.may add the Sphinx directory to PATH. echo. echo.If you don't have Sphinx installed, grab it from echo.http://sphinx-doc.org/ exit /b 1 ) if "%1" == "html" ( %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/html. goto end ) if "%1" == "dirhtml" ( %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. goto end ) if "%1" == "singlehtml" ( %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. goto end ) if "%1" == "pickle" ( %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the pickle files. goto end ) if "%1" == "json" ( %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the JSON files. goto end ) if "%1" == "htmlhelp" ( %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run HTML Help Workshop with the ^ .hhp project file in %BUILDDIR%/htmlhelp. goto end ) if "%1" == "qthelp" ( %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run "qcollectiongenerator" with the ^ .qhcp project file in %BUILDDIR%/qthelp, like this: echo.^> qcollectiongenerator %BUILDDIR%\qthelp\reflink.qhcp echo.To view the help file: echo.^> assistant -collectionFile %BUILDDIR%\qthelp\reflink.ghc goto end ) if "%1" == "devhelp" ( %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp if errorlevel 1 exit /b 1 echo. echo.Build finished. goto end ) if "%1" == "epub" ( %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub if errorlevel 1 exit /b 1 echo. echo.Build finished. The epub file is in %BUILDDIR%/epub. goto end ) if "%1" == "latex" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex if errorlevel 1 exit /b 1 echo. echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. goto end ) if "%1" == "latexpdf" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex cd %BUILDDIR%/latex make all-pdf cd %BUILDDIR%/.. echo. echo.Build finished; the PDF files are in %BUILDDIR%/latex. goto end ) if "%1" == "latexpdfja" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex cd %BUILDDIR%/latex make all-pdf-ja cd %BUILDDIR%/.. echo. echo.Build finished; the PDF files are in %BUILDDIR%/latex. goto end ) if "%1" == "text" ( %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text if errorlevel 1 exit /b 1 echo. echo.Build finished. The text files are in %BUILDDIR%/text. goto end ) if "%1" == "man" ( %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man if errorlevel 1 exit /b 1 echo. echo.Build finished. The manual pages are in %BUILDDIR%/man. goto end ) if "%1" == "texinfo" ( %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo if errorlevel 1 exit /b 1 echo. echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. goto end ) if "%1" == "gettext" ( %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale if errorlevel 1 exit /b 1 echo. echo.Build finished. The message catalogs are in %BUILDDIR%/locale. goto end ) if "%1" == "changes" ( %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes if errorlevel 1 exit /b 1 echo. echo.The overview file is in %BUILDDIR%/changes. goto end ) if "%1" == "linkcheck" ( %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck if errorlevel 1 exit /b 1 echo. echo.Link check complete; look for any errors in the above output ^ or in %BUILDDIR%/linkcheck/output.txt. goto end ) if "%1" == "doctest" ( %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest if errorlevel 1 exit /b 1 echo. echo.Testing of doctests in the sources finished, look at the ^ results in %BUILDDIR%/doctest/output.txt. goto end ) if "%1" == "xml" ( %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml if errorlevel 1 exit /b 1 echo. echo.Build finished. The XML files are in %BUILDDIR%/xml. goto end ) if "%1" == "pseudoxml" ( %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml if errorlevel 1 exit /b 1 echo. echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. goto end ) :end ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1501416131.0 reflink-0.2.2/docs/modules.rst0000644000175000017500000000007213137345303015406 0ustar00rsmetrsmetreflink ======= .. toctree:: :maxdepth: 4 reflink ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1501169719.0 reflink-0.2.2/docs/readme.rst0000644000175000017500000000003313136404067015172 0ustar00rsmetrsmet.. include:: ../README.rst ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1501416131.0 reflink-0.2.2/docs/reflink.rst0000644000175000017500000000131313137345303015367 0ustar00rsmetrsmetreflink package =============== Submodules ---------- reflink\.backend module ----------------------- .. automodule:: reflink.backend :members: :undoc-members: :show-inheritance: reflink\.error module --------------------- .. automodule:: reflink.error :members: :undoc-members: :show-inheritance: reflink\.linux module --------------------- .. automodule:: reflink.linux :members: :undoc-members: :show-inheritance: reflink\.reflink module ----------------------- .. automodule:: reflink.reflink :members: :undoc-members: :show-inheritance: Module contents --------------- .. automodule:: reflink :members: :undoc-members: :show-inheritance: ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1501250583.0 reflink-0.2.2/docs/usage.rst0000644000175000017500000000046513136642027015052 0ustar00rsmetrsmet===== Usage ===== To use Python reflink in a project:: import reflink from reflink import reflink reflink("large_file.img", "copy_of_file.img") Raises a ``NotImplementedError`` when the OS does not implement reflink. Raises a ``ReflinkImpossibleError`` when trying to reflink between devices, ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1693045909.1934023 reflink-0.2.2/reflink/0000755000175000017500000000000014472352225013713 5ustar00rsmetrsmet././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1520584136.0 reflink-0.2.2/reflink/__init__.py0000644000175000017500000000040413250442710016012 0ustar00rsmetrsmet# -*- coding: utf-8 -*- """Top-level package for Python reflink.""" __author__ = """Ruben De Smet""" __email__ = 'pypi@rubdos.be' __version__ = '0.1.3' from .error import ReflinkImpossibleError from .reflink import reflink from .reflink import supported_at ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1537855103.0 reflink-0.2.2/reflink/backend.py0000644000175000017500000000460213352347177015664 0ustar00rsmetrsmetimport errno import sys from ._backend import ffi # Ignore PyLintBear (E0611) from ._backend import lib from .error import ReflinkImpossibleError if sys.version_info[0] == 3: unicode = str def clone(oldpath, newpath): if isinstance(oldpath, unicode): oldpath = oldpath.encode(sys.getfilesystemencoding()) if isinstance(newpath, unicode): newpath = newpath.encode(sys.getfilesystemencoding()) newpath_c = ffi.new('char[]', newpath) oldpath_c = ffi.new('char[]', oldpath) rc = lib.reflink_clone_file(oldpath_c, newpath_c) if rc == 0: return # Success! if rc == -1: # ioctl returned an error. # We investigate in Python and throw if lib.errno == errno.EBADF: raise NotImplementedError( "BUG: errno EBADF when handling ioctl error") if lib.errno == errno.EINVAL: raise IOError( "EINVAL when handling ioctl: The filesystem does not support reflinking the ranges of the given files.") if lib.errno == errno.EISDIR: raise IOError("Cannot reflink directories") if lib.errno == errno.EOPNOTSUPP: raise ReflinkImpossibleError("EOPNOTSUPP") if lib.errno == errno.EPERM: raise IOError("EPERM: no permission to write to %s" % newpath) if lib.errno == errno.ETXTBSY: raise IOError("ETXTBSY: cannot reflink from/to swapfiles") if lib.errno == errno.EXDEV: raise ReflinkImpossibleError("EXDEV") if lib.errno == errno.ENOENT: raise FileNotFoundError( "Cannot open source file %s (%i)" % (oldpath, lib.errno)) raise Exception("BUG: errno %s not implemented" % errno.errorcode[lib.errno]) if rc == -3: raise IOError("Cannot open file %s for writing (%i)" % (newpath, lib.errno)) if rc == -2: if lib.errno == errno.ENOENT: raise FileNotFoundError("No such file %s (%i)" % (oldpath, lib.errno)) raise IOError("Cannot open source file %s (%i)" % (oldpath, lib.errno)) if rc == -4: raise NotImplementedError() if rc == -5: raise IOError("Could not copy permissions (errno %s)" % errno.errorcode[lib.errno]) raise IOError("Unknown exception (errno %s)" % errno.errorcode[lib.errno]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1693042814.0 reflink-0.2.2/reflink/darwin.c0000644000175000017500000000104014472344176015344 0ustar00rsmetrsmet#include /* NOTE: sys/clonefile.h is available since OS X 10.12 */ #if defined MAC_OS_X_VERSION_10_12 && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 #include /* for clonefile(2) */ #include int reflink_clone_file(char *oldpath, char *newpath) { int rc; rc = clonefile(oldpath, newpath, 0); if (rc == 0) return 0; if (errno == ENOTSUP) { return -4; } return rc; } #else int reflink_clone_file(char *oldpath, char *newpath) { return -4; } #endif ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1501240283.0 reflink-0.2.2/reflink/error.py0000644000175000017500000000006213136615733015416 0ustar00rsmetrsmetclass ReflinkImpossibleError(Exception): pass ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1520585363.0 reflink-0.2.2/reflink/linux.c0000644000175000017500000000173713250445223015220 0ustar00rsmetrsmet#include #include #include #include #include #include #include int clone_permissions(char *oldpath, char *newpath) { struct stat st; int rc; rc = stat(oldpath, &st); if (rc) { return rc; } return chmod(newpath, st.st_mode); // Ignore CSecurityBear (race) } int reflink_clone_file(char *oldpath, char *newpath) { #ifdef FICLONE int old_fd = open(oldpath, O_RDONLY); if (old_fd < 0) { return -2; } int new_fd = open(newpath, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR); if (new_fd < 0) { close(old_fd); return -3; } int result = ioctl (new_fd, FICLONE, old_fd); close(new_fd); close(old_fd); if (result != 0) { unlink(newpath); return result; } if (clone_permissions(oldpath, newpath)) { unlink(newpath); return -5; } return result; #else return -4; #endif } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1693042814.0 reflink-0.2.2/reflink/native.py0000644000175000017500000000071514472344176015564 0ustar00rsmetrsmetimport sys from cffi import FFI REFLINK_ATTR_PRESERVE = 0x1 REFLINK_ATTR_NONE = 0x0 platform = sys.platform if platform == 'linux2': platform = 'linux' ffibuilder = FFI() with open("reflink/%s.c" % platform) as source_file: ffibuilder.set_source("reflink._backend", source_file.read()) ffibuilder.cdef(""" int reflink_clone_file(char *oldpath, char *newpath); extern int errno; """) if __file__ == '__main__': ffibuilder.compile(verbose=True) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1520583937.0 reflink-0.2.2/reflink/reflink.py0000644000175000017500000000400513250442401015703 0ustar00rsmetrsmet# -*- coding: utf-8 -*- """Main module.""" import os from . import backend def reflink(oldpath, newpath): """ Create a reflink from ``newpath`` to ``oldpath``. Raises a ``NotImplementedError`` when the OS does not implement reflink. Raises a ``ReflinkImpossibleError`` when trying to reflink between devices, Raises an ``IOError`` when: * ``oldpath`` is a directory * The user has no permissions to create ``newpath`` * Trying to reflink into a swapfile (ETXTBSY) For debugability's sake, ``reflink`` _can_ throw IOError in other cases, when the underlying system call fails for another reason. However, these reasons cannot be triggered with this basic call. See man `IOCTL-FICLONERANGE(2) `__ and ``backend.py`` for more details on these conditions. Example code: >>> from reflink import reflink >>> reflink("large_file.img", "copy_of_file.img") # doctest: +SKIP >>> """ # raise NotImplementedError when OS does not implement reflink # raise ReflinkImpossibleError when trying to reflink across devices backend.clone(oldpath, newpath) def supported_at(path): """ Returns ``True`` when a path on the filesystem supports reflinking, ``False`` otherwise. Please note that the current implementation verifies this by testing whether it's possible to reflink. """ # Currently, there's no systemcall that tests whether a point in the VFS is supported or not. # We create a file at ``path``, and clone it. a = os.path.join(path, "i_hope_no_one_will_ever_try_this_name.txt") b = os.path.join(path, "i_hope_no_one_will_ever_try_that_name.txt") with open(a, 'w+') as f: f.write(u"abc") try: reflink(a, b) return True except: pass # TODO: there are probably specific exception that we can handle finally: os.unlink(a) if os.path.isfile(b): os.unlink(b) return False ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1501446608.0 reflink-0.2.2/reflink/win32.c0000644000175000017500000000010513137440720015010 0ustar00rsmetrsmetint reflink_clone_file(char *oldpath, char *newpath) { return -4; } ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1693045909.1944022 reflink-0.2.2/reflink.egg-info/0000755000175000017500000000000014472352225015405 5ustar00rsmetrsmet././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1693045909.0 reflink-0.2.2/reflink.egg-info/PKG-INFO0000644000175000017500000000730014472352225016502 0ustar00rsmetrsmetMetadata-Version: 2.1 Name: reflink Version: 0.2.2 Summary: Python reflink wraps around platform specific reflink implementations Home-page: https://gitlab.com/rubdos/pyreflink Author: Ruben De Smet Author-email: pypi@rubdos.be License: MIT license Keywords: reflink Classifier: Development Status :: 2 - Pre-Alpha Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License Classifier: Natural Language :: English Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 License-File: LICENSE License-File: AUTHORS.rst ============== Python reflink ============== .. image:: https://img.shields.io/pypi/v/reflink.svg :target: https://pypi.python.org/pypi/reflink .. image:: https://gitlab.com/rubdos/pyreflink/badges/master/build.svg :target: https://gitlab.com/rubdos/pyreflink/pipelines .. image:: https://ci.appveyor.com/api/projects/status/ta2rn0irw52ua5sw?svg=true :target: https://ci.appveyor.com/project/RubenDeSmet/pyreflink :alt: Windows build status .. image:: https://readthedocs.org/projects/reflink/badge/?version=latest :target: https://reflink.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status .. image:: https://readthedocs.org/projects/reflink/badge/?version=latest :target: https://rubdos.gitlab.io/pyreflink/docs :alt: Documentation Status .. image:: https://gitlab.com/rubdos/pyreflink/badges/master/coverage.svg :target: https://rubdos.gitlab.io/pyreflink/coverage :alt: Coverage report Python wrapper around the ``reflink`` system calls. Note: Python is implementing this natively upstream, cfr. https://bugs.python.org/issue37157. * Free software: MIT license * Documentation: https://reflink.readthedocs.io. * Documentation for master branch: https://rubdos.gitlab.io/pyreflink/docs Features -------- * Btrfs, XFS, OCFS2 ``reflink`` support. Btrfs is tested the most. * Apple macOS APFS ``clonefile`` support. Little testing, be careful. It might eat data. * A convenience method that checks support for reflinks within a specific directory. Installation ------------ This library is available on `pypi`_:: pip install reflink Quick start example ------------------- To use Python reflink in a project:: from reflink import reflink # Reflink copy 'large_file.img' to 'copy_of_file.img' reflink("large_file.img", "copy_of_file.img") Help wanted ----------- Someone to implement a `Windows/ReFS implementation `__ Support _______ Support on `the GitLab repository `__, feel free to file an issue. Credits --------- This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template. .. _Cookiecutter: https://github.com/audreyr/cookiecutter .. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage .. _pypi: https://pypi.python.org/pypi/reflink ======= History ======= 0.2.0 (2018-03-09) ------------------ New features: * APFS/Darwin support * Filenames outside ascii are supported (thank you, Kriskras99) Bug fixes: * Building on newer glibc (thank you, Frankie Dintino) * Better error handling for ENOENT Other changes: * Continuous integration for Windows (AppVeyor), integrated in the GitLab pipeline 0.1.0 (2017-07-27) ------------------ * First release on PyPI. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1693045909.0 reflink-0.2.2/reflink.egg-info/SOURCES.txt0000644000175000017500000000211214472352225017265 0ustar00rsmetrsmetAUTHORS.rst CONTRIBUTING.rst HISTORY.rst LICENSE MANIFEST.in README.rst setup.cfg setup.py docs/Makefile docs/authors.rst docs/conf.py docs/contributing.rst docs/history.rst docs/index.rst docs/installation.rst docs/make.bat docs/modules.rst docs/readme.rst docs/reflink.rst docs/usage.rst docs/_build/html/_static/ajax-loader.gif docs/_build/html/_static/comment-bright.png docs/_build/html/_static/comment-close.png docs/_build/html/_static/comment.png docs/_build/html/_static/down-pressed.png docs/_build/html/_static/down.png docs/_build/html/_static/file.png docs/_build/html/_static/minus.png docs/_build/html/_static/plus.png docs/_build/html/_static/up-pressed.png docs/_build/html/_static/up.png reflink/__init__.py reflink/backend.py reflink/darwin.c reflink/error.py reflink/linux.c reflink/native.py reflink/reflink.py reflink/win32.c reflink.egg-info/PKG-INFO reflink.egg-info/SOURCES.txt reflink.egg-info/dependency_links.txt reflink.egg-info/not-zip-safe reflink.egg-info/requires.txt reflink.egg-info/top_level.txt tests/__init__.py tests/test_reflink.py tests/test_reflink.py.orig././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1693045909.0 reflink-0.2.2/reflink.egg-info/dependency_links.txt0000644000175000017500000000000114472352225021453 0ustar00rsmetrsmet ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1501416349.0 reflink-0.2.2/reflink.egg-info/not-zip-safe0000644000175000017500000000000113137345635017637 0ustar00rsmetrsmet ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1693045909.0 reflink-0.2.2/reflink.egg-info/requires.txt0000644000175000017500000000000514472352225020000 0ustar00rsmetrsmetcffi ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1693045909.0 reflink-0.2.2/reflink.egg-info/top_level.txt0000644000175000017500000000001014472352225020126 0ustar00rsmetrsmetreflink ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1693045909.1954024 reflink-0.2.2/setup.cfg0000644000175000017500000000062414472352225014104 0ustar00rsmetrsmet[bumpversion] current_version = 0.1.3 commit = True tag = True [bumpversion:file:setup.py] search = version='{current_version}' replace = version='{new_version}' [bumpversion:file:reflink/__init__.py] search = __version__ = '{current_version}' replace = __version__ = '{new_version}' [bdist_wheel] universal = 1 [flake8] exclude = docs [aliases] test = pytest [egg_info] tag_build = tag_date = 0 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1693043032.0 reflink-0.2.2/setup.py0000644000175000017500000000364114472344530013777 0ustar00rsmetrsmet#!/usr/bin/env python # -*- coding: utf-8 -*- """The setup script.""" import sys from setuptools import find_packages from setuptools import setup with open('README.rst') as readme_file: readme = readme_file.read() with open('HISTORY.rst') as history_file: history = history_file.read() requirements = [ 'cffi', ] setup_requirements = [ 'cffi', 'pytest-runner', ] test_requirements = [ 'pytest', ] if sys.platform not in ['linux', 'linux2', 'win32', 'darwin']: raise NotImplementedError("Platform %s not supported" % sys.platform) if __name__ == '__main__': setup( name='reflink', version='0.2.2', description="Python reflink wraps around platform specific reflink implementations", long_description=readme + '\n\n' + history, author="Ruben De Smet", author_email='pypi@rubdos.be', url='https://gitlab.com/rubdos/pyreflink', packages=find_packages(include=['reflink']), include_package_data=True, install_requires=requirements, license="MIT license", zip_safe=False, keywords='reflink', classifiers=[ 'Development Status :: 2 - Pre-Alpha', 'Intended Audience :: Developers', 'License :: OSI Approved :: MIT License', 'Natural Language :: English', "Programming Language :: Python :: 2", 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', ], test_suite='tests', tests_require=test_requirements, setup_requires=setup_requirements, cffi_modules=["reflink/native.py:ffibuilder"] ) ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1693045909.1944022 reflink-0.2.2/tests/0000755000175000017500000000000014472352225013423 5ustar00rsmetrsmet././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1501169719.0 reflink-0.2.2/tests/__init__.py0000644000175000017500000000007613136404067015535 0ustar00rsmetrsmet# -*- coding: utf-8 -*- """Unit test package for reflink.""" ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1693042814.0 reflink-0.2.2/tests/test_reflink.py0000644000175000017500000000525114472344176016477 0ustar00rsmetrsmet#!/usr/bin/env python # -*- coding: utf-8 -*- """Tests for `reflink` package.""" import os import random import string import subprocess import sys import unittest import pytest from reflink import reflink from reflink import ReflinkImpossibleError from reflink import supported_at @pytest.fixture def btrfs_volume(tmpdir): path = tmpdir.join("volume") with open(path, 'bw+') as f: f.truncate(512 * 1024 ** 2) process = subprocess.call(["mkfs.btrfs", path]) assert process == 0 yield path os.remove(path) @pytest.fixture def btrfs_mount(tmpdir, btrfs_volume): mount = tmpdir.join("mount") os.mkdir(mount) process = subprocess.call(["mount", btrfs_volume, mount]) assert process == 0 yield mount process = subprocess.call(["umount", btrfs_volume]) assert process == 0 os.rmdir(mount) @pytest.fixture def file_on_mount(btrfs_mount): name = ''.join(random.choices(string.ascii_lowercase, k=8)) path = os.path.join(btrfs_mount, name) with open(path, 'bw+') as f: f.write(''.join(random.choices( string.ascii_lowercase, k=100)).encode('utf-8')) yield path os.remove(path) @pytest.mark.btrfs def test_reflink_with_file(btrfs_mount, file_on_mount): target = os.path.join(btrfs_mount, "target") reflink(file_on_mount, target) assert os.path.isfile(target) @pytest.mark.btrfs def test_reflink(btrfs_mount): source = os.path.join(btrfs_mount, "source") target = os.path.join(btrfs_mount, "target") with pytest.raises(FileNotFoundError): reflink(source, target) assert not os.path.isfile(source) assert not os.path.isfile(target) @pytest.mark.btrfs def test_reflink_unicode(btrfs_mount, file_on_mount): target = os.path.join(btrfs_mount, "❤") reflink(file_on_mount, target) assert os.path.isfile(target) @pytest.mark.btrfs def test_reflink_across_devices(btrfs_mount, file_on_mount, tmpdir): target = os.path.join(tmpdir, "target") with pytest.raises(ReflinkImpossibleError): reflink(file_on_mount, target) assert not os.path.isfile(target) @pytest.mark.btrfs def test_supported_at_btrfs(btrfs_mount): assert supported_at(btrfs_mount) @pytest.mark.btrfs def test_btrfs_permissions(btrfs_mount, file_on_mount): target = os.path.join(btrfs_mount, "target") reflink(file_on_mount, target) a = os.stat(file_on_mount) b = os.stat(target) assert a.st_mode == b.st_mode @unittest.skipUnless(sys.platform in ['linux', 'freebsd'], "No /dev support") def test_not_supported_at_dev(): try: assert not supported_at("/dev") except PermissionError: raise pytest.skip("/dev is not writeable") ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1520584431.0 reflink-0.2.2/tests/test_reflink.py.orig0000644000175000017500000000456013250443357017432 0ustar00rsmetrsmet#!/usr/bin/env python # -*- coding: utf-8 -*- """Tests for `reflink` package.""" import os import random import string import subprocess import sys import unittest import pytest from reflink import reflink from reflink import ReflinkImpossibleError from reflink import supported_at @pytest.fixture def btrfs_volume(tmpdir): path = tmpdir.join("volume") with open(path, 'bw+') as f: f.truncate(512 * 1024 ** 2) process = subprocess.call(["mkfs.btrfs", path]) assert process == 0 yield path os.remove(path) @pytest.fixture def btrfs_mount(tmpdir, btrfs_volume): mount = tmpdir.join("mount") os.mkdir(mount) process = subprocess.call(["mount", btrfs_volume, mount]) assert process == 0 yield mount process = subprocess.call(["umount", btrfs_volume]) assert process == 0 os.rmdir(mount) @pytest.fixture def file_on_mount(btrfs_mount): name = ''.join(random.choices(string.ascii_lowercase, k=8)) path = os.path.join(btrfs_mount, name) with open(path, 'bw+') as f: f.write(''.join(random.choices(string.ascii_lowercase, k=100)).encode('utf-8')) yield path os.remove(path) @pytest.mark.btrfs def test_reflink(btrfs_mount, file_on_mount): target = os.path.join(btrfs_mount, "target") reflink(file_on_mount, target) assert os.path.isfile(target) @pytest.mark.btrfs def test_reflink(btrfs_mount): source = os.path.join(btrfs_mount, "source") target = os.path.join(btrfs_mount, "target") with pytest.raises(FileNotFoundError): reflink(source, target) assert not os.path.isfile(source) assert not os.path.isfile(target) @pytest.mark.btrfs def test_reflink_across_devices(btrfs_mount, file_on_mount, tmpdir): target = os.path.join(tmpdir, "target") with pytest.raises(ReflinkImpossibleError): reflink(file_on_mount, target) assert not os.path.isfile(target) @pytest.mark.btrfs def test_supported_at_btrfs(btrfs_mount): assert supported_at(btrfs_mount) @pytest.mark.btrfs def test_btrfs_permissions(btrfs_mount, file_on_mount): target = os.path.join(btrfs_mount, "target") reflink(file_on_mount, target) a = os.stat(file_on_mount) b = os.stat(target) assert a.st_mode == b.st_mode @unittest.skipUnless(sys.platform in ['linux', 'freebsd'], "No /dev support") def test_not_supported_at_dev(): assert not supported_at("/dev")