From 5c112c798ce6736819ae9be258fa447936cfbbcd Mon Sep 17 00:00:00 2001 From: sylvestre Date: Sat, 8 Oct 2022 03:43:05 +0000 Subject: [PATCH] deploy: c249eba195809b51d95ea470b413d669888f9a27 --- dev/settings.html | 2 +- dev/source-files.js | 2 +- dev/src/uu_cp/cp.rs.html | 416 +-------------------------- dev/src/uu_cp/platform/linux.rs.html | 222 ++++++++++++++ dev/src/uu_cp/platform/mod.rs.html | 38 +++ dev/src/uu_split/filenames.rs.html | 116 +++++++- dev/src/uu_split/number.rs.html | 272 +++++++++--------- dev/src/uu_split/split.rs.html | 56 +++- dev/uu_cp/enum.Attribute.html | 18 +- dev/uu_cp/enum.ClobberMode.html | 8 +- dev/uu_cp/enum.CopyMode.html | 2 +- dev/uu_cp/enum.Error.html | 24 +- dev/uu_cp/enum.OverwriteMode.html | 10 +- dev/uu_cp/enum.ReflinkMode.html | 8 +- dev/uu_cp/enum.SparseMode.html | 8 +- dev/uu_cp/enum.TargetType.html | 2 +- dev/uu_cp/fn.localize_to_target.html | 2 +- dev/uu_cp/fn.path_has_prefix.html | 2 +- dev/uu_cp/fn.uu_app.html | 2 +- dev/uu_cp/fn.uumain.html | 2 +- dev/uu_cp/fn.verify_target_type.html | 2 +- dev/uu_cp/index.html | 2 +- dev/uu_cp/struct.Options.html | 2 +- dev/uu_cp/type.CopyResult.html | 2 +- dev/uu_cp/type.Source.html | 2 +- dev/uu_cp/type.SourceSlice.html | 2 +- dev/uu_cp/type.Target.html | 2 +- dev/uu_cp/type.TargetSlice.html | 2 +- dev/uu_split/index.html | 2 +- 29 files changed, 599 insertions(+), 631 deletions(-) create mode 100644 dev/src/uu_cp/platform/linux.rs.html create mode 100644 dev/src/uu_cp/platform/mod.rs.html diff --git a/dev/settings.html b/dev/settings.html index d66cdb06f..8241f8b4e 100644 --- a/dev/settings.html +++ b/dev/settings.html @@ -1 +1 @@ -Rustdoc settings

Rustdoc settings

Back
\ No newline at end of file +Rustdoc settings

Rustdoc settings

Back
\ No newline at end of file diff --git a/dev/source-files.js b/dev/source-files.js index be63987af..ed117765e 100644 --- a/dev/source-files.js +++ b/dev/source-files.js @@ -112,7 +112,7 @@ var sourcesIndex = JSON.parse('{\ "uu_chroot":["",[],["chroot.rs","error.rs"]],\ "uu_cksum":["",[],["cksum.rs"]],\ "uu_comm":["",[],["comm.rs"]],\ -"uu_cp":["",[],["cp.rs"]],\ +"uu_cp":["",[["platform",[],["linux.rs","mod.rs"]]],["cp.rs"]],\ "uu_csplit":["",[],["csplit.rs","csplit_error.rs","patterns.rs","split_name.rs"]],\ "uu_cut":["",[],["cut.rs","searcher.rs"]],\ "uu_date":["",[],["date.rs"]],\ diff --git a/dev/src/uu_cp/cp.rs.html b/dev/src/uu_cp/cp.rs.html index 9eda3b150..d7f445974 100644 --- a/dev/src/uu_cp/cp.rs.html +++ b/dev/src/uu_cp/cp.rs.html @@ -1684,210 +1684,6 @@ 1684 1685 1686 -1687 -1688 -1689 -1690 -1691 -1692 -1693 -1694 -1695 -1696 -1697 -1698 -1699 -1700 -1701 -1702 -1703 -1704 -1705 -1706 -1707 -1708 -1709 -1710 -1711 -1712 -1713 -1714 -1715 -1716 -1717 -1718 -1719 -1720 -1721 -1722 -1723 -1724 -1725 -1726 -1727 -1728 -1729 -1730 -1731 -1732 -1733 -1734 -1735 -1736 -1737 -1738 -1739 -1740 -1741 -1742 -1743 -1744 -1745 -1746 -1747 -1748 -1749 -1750 -1751 -1752 -1753 -1754 -1755 -1756 -1757 -1758 -1759 -1760 -1761 -1762 -1763 -1764 -1765 -1766 -1767 -1768 -1769 -1770 -1771 -1772 -1773 -1774 -1775 -1776 -1777 -1778 -1779 -1780 -1781 -1782 -1783 -1784 -1785 -1786 -1787 -1788 -1789 -1790 -1791 -1792 -1793 -1794 -1795 -1796 -1797 -1798 -1799 -1800 -1801 -1802 -1803 -1804 -1805 -1806 -1807 -1808 -1809 -1810 -1811 -1812 -1813 -1814 -1815 -1816 -1817 -1818 -1819 -1820 -1821 -1822 -1823 -1824 -1825 -1826 -1827 -1828 -1829 -1830 -1831 -1832 -1833 -1834 -1835 -1836 -1837 -1838 -1839 -1840 -1841 -1842 -1843 -1844 -1845 -1846 -1847 -1848 -1849 -1850 -1851 -1852 -1853 -1854 -1855 -1856 -1857 -1858 -1859 -1860 -1861 -1862 -1863 -1864 -1865 -1866 -1867 -1868 -1869 -1870 -1871 -1872 -1873 -1874 -1875 -1876 -1877 -1878 -1879 -1880 -1881 -1882 -1883 -1884 -1885 -1886 -1887 -1888 -1889 -1890
#![allow(clippy::missing_safety_doc)]
 #![allow(clippy::extra_unused_lifetimes)]
 
@@ -1912,15 +1708,11 @@
 #[cfg(not(windows))]
 use std::ffi::CString;
 use std::fs::{self, File, OpenOptions};
-#[cfg(any(target_os = "linux", target_os = "android"))]
-use std::io::Read;
 use std::io::{self, stderr, stdin, Write};
 #[cfg(unix)]
 use std::os::unix::ffi::OsStrExt;
 #[cfg(unix)]
 use std::os::unix::fs::{FileTypeExt, PermissionsExt};
-#[cfg(any(target_os = "linux", target_os = "android"))]
-use std::os::unix::io::AsRawFd;
 use std::path::{Path, PathBuf, StripPrefixError};
 use std::str::FromStr;
 use std::string::ToString;
@@ -1939,6 +1731,9 @@
 };
 use walkdir::WalkDir;
 
+mod platform;
+use platform::copy_on_write;
+
 quick_error! {
     #[derive(Debug)]
     pub enum Error {
@@ -2114,16 +1909,6 @@
     verbose: bool,
 }
 
-// From /usr/include/linux/fs.h:
-// #define FICLONE		_IOW(0x94, 9, int)
-#[cfg(any(target_os = "linux", target_os = "android"))]
-// Use a macro as libc::ioctl expects u32 or u64 depending on the arch
-macro_rules! FICLONE {
-    () => {
-        0x40049409
-    };
-}
-
 static ABOUT: &str = "Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.";
 static LONG_HELP: &str = "";
 static EXIT_ERR: i32 = 1;
@@ -3479,26 +3264,7 @@
     } else if source_is_symlink {
         copy_link(source, dest, symlinked_files)?;
     } else {
-        #[cfg(target_os = "macos")]
-        copy_on_write_macos(
-            source,
-            dest,
-            options.reflink_mode,
-            options.sparse_mode,
-            context,
-        )?;
-
-        #[cfg(any(target_os = "linux", target_os = "android"))]
-        copy_on_write_linux(
-            source,
-            dest,
-            options.reflink_mode,
-            options.sparse_mode,
-            context,
-        )?;
-
-        #[cfg(not(any(target_os = "linux", target_os = "android", target_os = "macos")))]
-        copy_no_cow_fallback(
+        copy_on_write(
             source,
             dest,
             options.reflink_mode,
@@ -3554,180 +3320,6 @@
     symlink_file(&link, &dest, &context_for(&link, &dest), symlinked_files)
 }
 
-/// Copies `source` to `dest` for systems without copy-on-write
-#[cfg(not(any(target_os = "linux", target_os = "android", target_os = "macos")))]
-fn copy_no_cow_fallback(
-    source: &Path,
-    dest: &Path,
-    reflink_mode: ReflinkMode,
-    sparse_mode: SparseMode,
-    context: &str,
-) -> CopyResult<()> {
-    if reflink_mode != ReflinkMode::Never {
-        return Err("--reflink is only supported on linux and macOS"
-            .to_string()
-            .into());
-    }
-    if sparse_mode != SparseMode::Auto {
-        return Err("--sparse is only supported on linux".to_string().into());
-    }
-
-    fs::copy(source, dest).context(context)?;
-
-    Ok(())
-}
-
-/// Use the Linux `ioctl_ficlone` API to do a copy-on-write clone.
-///
-/// If `fallback` is true and there is a failure performing the clone,
-/// then this function performs a standard [`std::fs::copy`]. Otherwise,
-/// this function returns an error.
-#[cfg(any(target_os = "linux", target_os = "android"))]
-fn clone<P>(source: P, dest: P, fallback: bool) -> std::io::Result<()>
-where
-    P: AsRef<Path>,
-{
-    let src_file = File::open(&source)?;
-    let dst_file = File::create(&dest)?;
-    let src_fd = src_file.as_raw_fd();
-    let dst_fd = dst_file.as_raw_fd();
-    let result = unsafe { libc::ioctl(dst_fd, FICLONE!(), src_fd) };
-    if result != 0 {
-        if fallback {
-            std::fs::copy(source, dest).map(|_| ())
-        } else {
-            Err(std::io::Error::last_os_error())
-        }
-    } else {
-        Ok(())
-    }
-}
-
-/// Perform a sparse copy from one file to another.
-#[cfg(any(target_os = "linux", target_os = "android"))]
-fn sparse_copy<P>(source: P, dest: P) -> std::io::Result<()>
-where
-    P: AsRef<Path>,
-{
-    use std::os::unix::prelude::MetadataExt;
-
-    let mut src_file = File::open(source)?;
-    let dst_file = File::create(dest)?;
-    let dst_fd = dst_file.as_raw_fd();
-
-    let size: usize = src_file.metadata()?.size().try_into().unwrap();
-    if unsafe { libc::ftruncate(dst_fd, size.try_into().unwrap()) } < 0 {
-        return Err(std::io::Error::last_os_error());
-    }
-
-    let blksize = dst_file.metadata()?.blksize();
-    let mut buf: Vec<u8> = vec![0; blksize.try_into().unwrap()];
-    let mut current_offset: usize = 0;
-
-    // TODO Perhaps we can employ the "fiemap ioctl" API to get the
-    // file extent mappings:
-    // https://www.kernel.org/doc/html/latest/filesystems/fiemap.html
-    while current_offset < size {
-        let this_read = src_file.read(&mut buf)?;
-        if buf.iter().any(|&x| x != 0) {
-            unsafe {
-                libc::pwrite(
-                    dst_fd,
-                    buf.as_ptr() as *const libc::c_void,
-                    this_read,
-                    current_offset.try_into().unwrap(),
-                )
-            };
-        }
-        current_offset += this_read;
-    }
-    Ok(())
-}
-
-/// Copies `source` to `dest` using copy-on-write if possible.
-#[cfg(any(target_os = "linux", target_os = "android"))]
-fn copy_on_write_linux(
-    source: &Path,
-    dest: &Path,
-    reflink_mode: ReflinkMode,
-    sparse_mode: SparseMode,
-    context: &str,
-) -> CopyResult<()> {
-    let result = match (reflink_mode, sparse_mode) {
-        (ReflinkMode::Never, _) => std::fs::copy(source, dest).map(|_| ()),
-        (ReflinkMode::Auto, SparseMode::Always) => sparse_copy(source, dest),
-        (ReflinkMode::Auto, _) => clone(source, dest, true),
-        (ReflinkMode::Always, SparseMode::Auto) => clone(source, dest, false),
-        (ReflinkMode::Always, _) => {
-            return Err("`--reflink=always` can be used only with --sparse=auto".into())
-        }
-    };
-    result.context(context)?;
-    Ok(())
-}
-
-/// Copies `source` to `dest` using copy-on-write if possible.
-#[cfg(target_os = "macos")]
-fn copy_on_write_macos(
-    source: &Path,
-    dest: &Path,
-    reflink_mode: ReflinkMode,
-    sparse_mode: SparseMode,
-    context: &str,
-) -> CopyResult<()> {
-    if sparse_mode != SparseMode::Auto {
-        return Err("--sparse is only supported on linux".to_string().into());
-    }
-
-    // Extract paths in a form suitable to be passed to a syscall.
-    // The unwrap() is safe because they come from the command-line and so contain non nul
-    // character.
-    let src = CString::new(source.as_os_str().as_bytes()).unwrap();
-    let dst = CString::new(dest.as_os_str().as_bytes()).unwrap();
-
-    // clonefile(2) was introduced in macOS 10.12 so we cannot statically link against it
-    // for backward compatibility.
-    let clonefile = CString::new("clonefile").unwrap();
-    let raw_pfn = unsafe { libc::dlsym(libc::RTLD_NEXT, clonefile.as_ptr()) };
-
-    let mut error = 0;
-    if !raw_pfn.is_null() {
-        // Call clonefile(2).
-        // Safety: Casting a C function pointer to a rust function value is one of the few
-        // blessed uses of `transmute()`.
-        unsafe {
-            let pfn: extern "C" fn(
-                src: *const libc::c_char,
-                dst: *const libc::c_char,
-                flags: u32,
-            ) -> libc::c_int = std::mem::transmute(raw_pfn);
-            error = pfn(src.as_ptr(), dst.as_ptr(), 0);
-            if std::io::Error::last_os_error().kind() == std::io::ErrorKind::AlreadyExists {
-                // clonefile(2) fails if the destination exists.  Remove it and try again.  Do not
-                // bother to check if removal worked because we're going to try to clone again.
-                let _ = fs::remove_file(dest);
-                error = pfn(src.as_ptr(), dst.as_ptr(), 0);
-            }
-        }
-    }
-
-    if raw_pfn.is_null() || error != 0 {
-        // clonefile(2) is either not supported or it errored out (possibly because the FS does not
-        // support COW).
-        match reflink_mode {
-            ReflinkMode::Always => {
-                return Err(
-                    format!("failed to clone {:?} from {:?}: {}", source, dest, error).into(),
-                )
-            }
-            ReflinkMode::Auto => fs::copy(source, dest).context(context)?,
-            ReflinkMode::Never => fs::copy(source, dest).context(context)?,
-        };
-    }
-
-    Ok(())
-}
-
 /// Generate an error message if `target` is not the correct `target_type`
 pub fn verify_target_type(target: &Path, target_type: &TargetType) -> CopyResult<()> {
     match (target_type, target.is_dir()) {
diff --git a/dev/src/uu_cp/platform/linux.rs.html b/dev/src/uu_cp/platform/linux.rs.html
new file mode 100644
index 000000000..b6898c97a
--- /dev/null
+++ b/dev/src/uu_cp/platform/linux.rs.html
@@ -0,0 +1,222 @@
+linux.rs - source
1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+
//  * This file is part of the uutils coreutils package.
+//  *
+//  * For the full copyright and license information, please view the LICENSE
+//  * file that was distributed with this source code.
+// spell-checker:ignore ficlone reflink ftruncate pwrite fiemap
+use std::fs::File;
+use std::io::Read;
+use std::os::unix::io::AsRawFd;
+use std::path::Path;
+
+use quick_error::ResultExt;
+
+use crate::{CopyResult, ReflinkMode, SparseMode};
+
+// From /usr/include/linux/fs.h:
+// #define FICLONE		_IOW(0x94, 9, int)
+// Use a macro as libc::ioctl expects u32 or u64 depending on the arch
+macro_rules! FICLONE {
+    () => {
+        0x40049409
+    };
+}
+
+/// Use the Linux `ioctl_ficlone` API to do a copy-on-write clone.
+///
+/// If `fallback` is true and there is a failure performing the clone,
+/// then this function performs a standard [`std::fs::copy`]. Otherwise,
+/// this function returns an error.
+#[cfg(any(target_os = "linux", target_os = "android"))]
+fn clone<P>(source: P, dest: P, fallback: bool) -> std::io::Result<()>
+where
+    P: AsRef<Path>,
+{
+    let src_file = File::open(&source)?;
+    let dst_file = File::create(&dest)?;
+    let src_fd = src_file.as_raw_fd();
+    let dst_fd = dst_file.as_raw_fd();
+    let result = unsafe { libc::ioctl(dst_fd, FICLONE!(), src_fd) };
+    if result != 0 {
+        if fallback {
+            std::fs::copy(source, dest).map(|_| ())
+        } else {
+            Err(std::io::Error::last_os_error())
+        }
+    } else {
+        Ok(())
+    }
+}
+
+/// Perform a sparse copy from one file to another.
+#[cfg(any(target_os = "linux", target_os = "android"))]
+fn sparse_copy<P>(source: P, dest: P) -> std::io::Result<()>
+where
+    P: AsRef<Path>,
+{
+    use std::os::unix::prelude::MetadataExt;
+
+    let mut src_file = File::open(source)?;
+    let dst_file = File::create(dest)?;
+    let dst_fd = dst_file.as_raw_fd();
+
+    let size: usize = src_file.metadata()?.size().try_into().unwrap();
+    if unsafe { libc::ftruncate(dst_fd, size.try_into().unwrap()) } < 0 {
+        return Err(std::io::Error::last_os_error());
+    }
+
+    let blksize = dst_file.metadata()?.blksize();
+    let mut buf: Vec<u8> = vec![0; blksize.try_into().unwrap()];
+    let mut current_offset: usize = 0;
+
+    // TODO Perhaps we can employ the "fiemap ioctl" API to get the
+    // file extent mappings:
+    // https://www.kernel.org/doc/html/latest/filesystems/fiemap.html
+    while current_offset < size {
+        let this_read = src_file.read(&mut buf)?;
+        if buf.iter().any(|&x| x != 0) {
+            unsafe {
+                libc::pwrite(
+                    dst_fd,
+                    buf.as_ptr() as *const libc::c_void,
+                    this_read,
+                    current_offset.try_into().unwrap(),
+                )
+            };
+        }
+        current_offset += this_read;
+    }
+    Ok(())
+}
+
+/// Copies `source` to `dest` using copy-on-write if possible.
+pub(crate) fn copy_on_write(
+    source: &Path,
+    dest: &Path,
+    reflink_mode: ReflinkMode,
+    sparse_mode: SparseMode,
+    context: &str,
+) -> CopyResult<()> {
+    let result = match (reflink_mode, sparse_mode) {
+        (ReflinkMode::Never, _) => std::fs::copy(source, dest).map(|_| ()),
+        (ReflinkMode::Auto, SparseMode::Always) => sparse_copy(source, dest),
+        (ReflinkMode::Auto, _) => clone(source, dest, true),
+        (ReflinkMode::Always, SparseMode::Auto) => clone(source, dest, false),
+        (ReflinkMode::Always, _) => {
+            return Err("`--reflink=always` can be used only with --sparse=auto".into())
+        }
+    };
+    result.context(context)?;
+    Ok(())
+}
+
+
\ No newline at end of file diff --git a/dev/src/uu_cp/platform/mod.rs.html b/dev/src/uu_cp/platform/mod.rs.html new file mode 100644 index 000000000..284aba676 --- /dev/null +++ b/dev/src/uu_cp/platform/mod.rs.html @@ -0,0 +1,38 @@ +mod.rs - source
1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+
//  * This file is part of the uutils coreutils package.
+//  *
+//  * For the full copyright and license information, please view the LICENSE
+//  * file that was distributed with this source code.
+#[cfg(target_os = "macos")]
+mod macos;
+#[cfg(target_os = "macos")]
+pub(crate) use self::macos::copy_on_write;
+
+#[cfg(any(target_os = "linux", target_os = "android"))]
+mod linux;
+#[cfg(any(target_os = "linux", target_os = "android"))]
+pub(crate) use self::linux::copy_on_write;
+
+#[cfg(not(any(target_os = "linux", target_os = "android", target_os = "macos")))]
+mod other;
+#[cfg(not(any(target_os = "linux", target_os = "android", target_os = "macos")))]
+pub(crate) use self::other::copy_on_write;
+
+
\ No newline at end of file diff --git a/dev/src/uu_split/filenames.rs.html b/dev/src/uu_split/filenames.rs.html index b5a80c91f..f34cb292f 100644 --- a/dev/src/uu_split/filenames.rs.html +++ b/dev/src/uu_split/filenames.rs.html @@ -209,6 +209,51 @@ 209 210 211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256
//  * This file is part of the uutils coreutils package.
 //  *
 //  * For the full copyright and license information, please view the LICENSE
@@ -239,6 +284,7 @@
 use crate::number::DynamicWidthNumber;
 use crate::number::FixedWidthNumber;
 use crate::number::Number;
+use uucore::error::{UResult, USimpleError};
 
 /// The format to use for suffixes in the filename for each output chunk.
 #[derive(Clone, Copy)]
@@ -330,19 +376,28 @@
         additional_suffix: &'a str,
         suffix_length: usize,
         suffix_type: SuffixType,
-    ) -> FilenameIterator<'a> {
+        suffix_start: usize,
+    ) -> UResult<FilenameIterator<'a>> {
         let radix = suffix_type.radix();
         let number = if suffix_length == 0 {
-            Number::DynamicWidth(DynamicWidthNumber::new(radix))
+            Number::DynamicWidth(DynamicWidthNumber::new(radix, suffix_start))
         } else {
-            Number::FixedWidth(FixedWidthNumber::new(radix, suffix_length))
+            Number::FixedWidth(
+                FixedWidthNumber::new(radix, suffix_length, suffix_start).map_err(|_| {
+                    USimpleError::new(
+                        1,
+                        "numerical suffix start value is too large for the suffix length",
+                    )
+                })?,
+            )
         };
-        FilenameIterator {
+
+        Ok(FilenameIterator {
             prefix,
             additional_suffix,
             number,
             first_iteration: true,
-        }
+        })
     }
 }
 
@@ -372,36 +427,36 @@
 
     #[test]
     fn test_filename_iterator_alphabetic_fixed_width() {
-        let mut it = FilenameIterator::new("chunk_", ".txt", 2, SuffixType::Alphabetic);
+        let mut it = FilenameIterator::new("chunk_", ".txt", 2, SuffixType::Alphabetic, 0).unwrap();
         assert_eq!(it.next().unwrap(), "chunk_aa.txt");
         assert_eq!(it.next().unwrap(), "chunk_ab.txt");
         assert_eq!(it.next().unwrap(), "chunk_ac.txt");
 
-        let mut it = FilenameIterator::new("chunk_", ".txt", 2, SuffixType::Alphabetic);
+        let mut it = FilenameIterator::new("chunk_", ".txt", 2, SuffixType::Alphabetic, 0).unwrap();
         assert_eq!(it.nth(26 * 26 - 1).unwrap(), "chunk_zz.txt");
         assert_eq!(it.next(), None);
     }
 
     #[test]
     fn test_filename_iterator_numeric_fixed_width() {
-        let mut it = FilenameIterator::new("chunk_", ".txt", 2, SuffixType::Decimal);
+        let mut it = FilenameIterator::new("chunk_", ".txt", 2, SuffixType::Decimal, 0).unwrap();
         assert_eq!(it.next().unwrap(), "chunk_00.txt");
         assert_eq!(it.next().unwrap(), "chunk_01.txt");
         assert_eq!(it.next().unwrap(), "chunk_02.txt");
 
-        let mut it = FilenameIterator::new("chunk_", ".txt", 2, SuffixType::Decimal);
+        let mut it = FilenameIterator::new("chunk_", ".txt", 2, SuffixType::Decimal, 0).unwrap();
         assert_eq!(it.nth(10 * 10 - 1).unwrap(), "chunk_99.txt");
         assert_eq!(it.next(), None);
     }
 
     #[test]
     fn test_filename_iterator_alphabetic_dynamic_width() {
-        let mut it = FilenameIterator::new("chunk_", ".txt", 0, SuffixType::Alphabetic);
+        let mut it = FilenameIterator::new("chunk_", ".txt", 0, SuffixType::Alphabetic, 0).unwrap();
         assert_eq!(it.next().unwrap(), "chunk_aa.txt");
         assert_eq!(it.next().unwrap(), "chunk_ab.txt");
         assert_eq!(it.next().unwrap(), "chunk_ac.txt");
 
-        let mut it = FilenameIterator::new("chunk_", ".txt", 0, SuffixType::Alphabetic);
+        let mut it = FilenameIterator::new("chunk_", ".txt", 0, SuffixType::Alphabetic, 0).unwrap();
         assert_eq!(it.nth(26 * 25 - 1).unwrap(), "chunk_yz.txt");
         assert_eq!(it.next().unwrap(), "chunk_zaaa.txt");
         assert_eq!(it.next().unwrap(), "chunk_zaab.txt");
@@ -409,16 +464,51 @@
 
     #[test]
     fn test_filename_iterator_numeric_dynamic_width() {
-        let mut it = FilenameIterator::new("chunk_", ".txt", 0, SuffixType::Decimal);
+        let mut it = FilenameIterator::new("chunk_", ".txt", 0, SuffixType::Decimal, 0).unwrap();
         assert_eq!(it.next().unwrap(), "chunk_00.txt");
         assert_eq!(it.next().unwrap(), "chunk_01.txt");
         assert_eq!(it.next().unwrap(), "chunk_02.txt");
 
-        let mut it = FilenameIterator::new("chunk_", ".txt", 0, SuffixType::Decimal);
+        let mut it = FilenameIterator::new("chunk_", ".txt", 0, SuffixType::Decimal, 0).unwrap();
         assert_eq!(it.nth(10 * 9 - 1).unwrap(), "chunk_89.txt");
         assert_eq!(it.next().unwrap(), "chunk_9000.txt");
         assert_eq!(it.next().unwrap(), "chunk_9001.txt");
     }
+
+    #[test]
+    fn test_filename_iterator_numeric_suffix_decimal() {
+        let mut it = FilenameIterator::new("chunk_", ".txt", 0, SuffixType::Decimal, 5).unwrap();
+        assert_eq!(it.next().unwrap(), "chunk_05.txt");
+        assert_eq!(it.next().unwrap(), "chunk_06.txt");
+        assert_eq!(it.next().unwrap(), "chunk_07.txt");
+    }
+
+    #[test]
+    fn test_filename_iterator_numeric_suffix_hex() {
+        let mut it =
+            FilenameIterator::new("chunk_", ".txt", 0, SuffixType::Hexadecimal, 9).unwrap();
+        assert_eq!(it.next().unwrap(), "chunk_09.txt");
+        assert_eq!(it.next().unwrap(), "chunk_0a.txt");
+        assert_eq!(it.next().unwrap(), "chunk_0b.txt");
+    }
+
+    #[test]
+    fn test_filename_iterator_numeric_suffix_err() {
+        let mut it = FilenameIterator::new("chunk_", ".txt", 3, SuffixType::Decimal, 999).unwrap();
+        assert_eq!(it.next().unwrap(), "chunk_999.txt");
+        assert!(it.next().is_none());
+
+        let it = FilenameIterator::new("chunk_", ".txt", 3, SuffixType::Decimal, 1000);
+        assert!(it.is_err());
+
+        let mut it =
+            FilenameIterator::new("chunk_", ".txt", 3, SuffixType::Hexadecimal, 0xfff).unwrap();
+        assert_eq!(it.next().unwrap(), "chunk_fff.txt");
+        assert!(it.next().is_none());
+
+        let it = FilenameIterator::new("chunk_", ".txt", 3, SuffixType::Hexadecimal, 0x1000);
+        assert!(it.is_err());
+    }
 }
 
\ No newline at end of file diff --git a/dev/src/uu_split/number.rs.html b/dev/src/uu_split/number.rs.html index 90b99837f..baa3a5e81 100644 --- a/dev/src/uu_split/number.rs.html +++ b/dev/src/uu_split/number.rs.html @@ -580,10 +580,6 @@ 580 581 582 -583 -584 -585 -586
//  * This file is part of the uutils coreutils package.
 //  *
 //  * For the full copyright and license information, please view the LICENSE
@@ -686,10 +682,10 @@
     /// differently and we only intend to use these numbers for display
     /// purposes and not for mathematical purposes.
     #[allow(dead_code)]
-    fn digits(&self) -> &Vec<u8> {
+    fn digits(&self) -> Vec<u8> {
         match self {
-            Self::FixedWidth(number) => &number.digits,
-            Self::DynamicWidth(number) => &number.digits,
+            Self::FixedWidth(number) => number.digits.clone(),
+            Self::DynamicWidth(number) => number.digits(),
         }
     }
 
@@ -761,7 +757,7 @@
 ///
 /// # Displaying
 ///
-/// This number is only displayable if `radix` is 10, 26, or 26. If
+/// This number is only displayable if `radix` is 10, 16, or 26. If
 /// `radix` is 10 or 16, then the digits are concatenated and
 /// displayed as a fixed-width decimal or hexadecimal number,
 /// respectively. If `radix` is 26, then each digit is translated to
@@ -775,10 +771,21 @@
 
 impl FixedWidthNumber {
     /// Instantiate a number of the given radix and width.
-    pub fn new(radix: u8, width: usize) -> Self {
-        Self {
-            radix,
-            digits: vec![0; width],
+    pub fn new(radix: u8, width: usize, mut suffix_start: usize) -> Result<Self, Overflow> {
+        let mut digits = vec![0_u8; width];
+
+        for i in (0..digits.len()).rev() {
+            let remainder = (suffix_start % (radix as usize)) as u8;
+            suffix_start /= radix as usize;
+            digits[i] = remainder;
+            if suffix_start == 0 {
+                break;
+            }
+        }
+        if suffix_start != 0 {
+            Err(Overflow)
+        } else {
+            Ok(Self { radix, digits })
         }
     }
 
@@ -815,25 +822,12 @@
 
 impl Display for FixedWidthNumber {
     fn fmt(&self, f: &mut Formatter) -> fmt::Result {
-        match self.radix {
-            10 => {
-                let digits: String = self.digits.iter().map(|d| (b'0' + d) as char).collect();
-                write!(f, "{}", digits)
-            }
-            16 => {
-                let digits: String = self
-                    .digits
-                    .iter()
-                    .map(|d| (if *d < 10 { b'0' + d } else { b'a' + (d - 10) }) as char)
-                    .collect();
-                write!(f, "{}", digits)
-            }
-            26 => {
-                let digits: String = self.digits.iter().map(|d| (b'a' + d) as char).collect();
-                write!(f, "{}", digits)
-            }
-            _ => Err(fmt::Error),
-        }
+        let digits: String = self
+            .digits
+            .iter()
+            .map(|d| map_digit(self.radix, *d))
+            .collect();
+        write!(f, "{}", digits)
     }
 }
 
@@ -879,105 +873,74 @@
 #[derive(Clone)]
 pub struct DynamicWidthNumber {
     radix: u8,
-    digits: Vec<u8>,
+    current: usize,
 }
 
 impl DynamicWidthNumber {
-    /// Instantiate a number of the given radix, starting with width 2.
-    ///
-    /// This associated function returns a new instance of the struct
-    /// with the given radix and a width of two digits, both 0.
-    pub fn new(radix: u8) -> Self {
+    pub fn new(radix: u8, suffix_start: usize) -> Self {
         Self {
             radix,
-            digits: vec![0, 0],
+            current: suffix_start,
         }
     }
 
-    /// Set all digits to zero.
-    fn reset(&mut self) {
-        for i in 0..self.digits.len() {
-            self.digits[i] = 0;
-        }
-    }
-
-    /// Increment this number.
-    ///
-    /// This method adds one to this number. The first time that the
-    /// most significant digit would achieve its highest possible
-    /// value (that is, `radix - 1`), then all the digits get reset to
-    /// 0 and the number of digits increases by one.
-    ///
-    /// This method never returns an error.
     fn increment(&mut self) -> Result<(), Overflow> {
-        for i in (0..self.digits.len()).rev() {
-            // Increment the current digit.
-            self.digits[i] += 1;
-
-            // If the digit overflows, then set it to 0 and continue
-            // to the next iteration to increment the next most
-            // significant digit. Otherwise, terminate the loop, since
-            // there will be no further changes to any higher order
-            // digits.
-            if self.digits[i] == self.radix {
-                self.digits[i] = 0;
-            } else {
-                break;
-            }
-        }
-
-        // If the most significant digit is at its maximum value, then
-        // add another digit and reset all digits zero.
-        if self.digits[0] == self.radix - 1 {
-            self.digits.push(0);
-            self.reset();
-        }
+        self.current += 1;
         Ok(())
     }
+
+    fn digits(&self) -> Vec<u8> {
+        let radix = self.radix as usize;
+        let mut remaining = self.current;
+        let mut sub_value = (radix - 1) * radix;
+        let mut num_fill_chars = 2;
+
+        // Convert the number into "num_fill_chars" and "remaining"
+        while remaining >= sub_value {
+            remaining -= sub_value;
+            sub_value *= radix;
+            num_fill_chars += 1;
+        }
+
+        // Convert the "remainder" to digits
+        let mut digits = Vec::new();
+        while remaining > 0 {
+            digits.push((remaining % radix) as u8);
+            remaining /= radix;
+        }
+        // Left pad the vec
+        digits.resize(num_fill_chars, 0);
+        digits.reverse();
+        digits
+    }
+}
+
+fn map_digit(radix: u8, d: u8) -> char {
+    (match radix {
+        10 => b'0' + d,
+        16 => {
+            if d < 10 {
+                b'0' + d
+            } else {
+                b'a' + (d - 10)
+            }
+        }
+        26 => b'a' + d,
+        _ => 0,
+    }) as char
 }
 
 impl Display for DynamicWidthNumber {
     fn fmt(&self, f: &mut Formatter) -> fmt::Result {
-        match self.radix {
-            10 => {
-                let num_fill_chars = self.digits.len() - 2;
-                let digits: String = self.digits.iter().map(|d| (b'0' + d) as char).collect();
-                write!(
-                    f,
-                    "{empty:9<num_fill_chars$}{digits}",
-                    empty = "",
-                    num_fill_chars = num_fill_chars,
-                    digits = digits,
-                )
-            }
-            16 => {
-                let num_fill_chars = self.digits.len() - 2;
-                let digits: String = self
-                    .digits
-                    .iter()
-                    .map(|d| (if *d < 10 { b'0' + d } else { b'a' + (d - 10) }) as char)
-                    .collect();
-                write!(
-                    f,
-                    "{empty:f<num_fill_chars$}{digits}",
-                    empty = "",
-                    num_fill_chars = num_fill_chars,
-                    digits = digits,
-                )
-            }
-            26 => {
-                let num_fill_chars = self.digits.len() - 2;
-                let digits: String = self.digits.iter().map(|d| (b'a' + d) as char).collect();
-                write!(
-                    f,
-                    "{empty:z<num_fill_chars$}{digits}",
-                    empty = "",
-                    num_fill_chars = num_fill_chars,
-                    digits = digits,
-                )
-            }
-            _ => Err(fmt::Error),
-        }
+        let digits: String = self
+            .digits()
+            .iter()
+            .map(|d| map_digit(self.radix, *d))
+            .collect();
+        let fill: String = (0..digits.len() - 2)
+            .map(|_| map_digit(self.radix, self.radix - 1))
+            .collect();
+        write!(f, "{fill}{digits}")
     }
 }
 
@@ -990,35 +953,36 @@
 
     #[test]
     fn test_dynamic_width_number_increment() {
-        let mut n = Number::DynamicWidth(DynamicWidthNumber::new(3));
-        assert_eq!(n.digits(), &vec![0, 0]);
+        println!("Here");
+        let mut n = Number::DynamicWidth(DynamicWidthNumber::new(3, 0));
+        assert_eq!(n.digits(), vec![0, 0]);
 
         n.increment().unwrap();
-        assert_eq!(n.digits(), &vec![0, 1]);
+        assert_eq!(n.digits(), vec![0, 1]);
 
         n.increment().unwrap();
-        assert_eq!(n.digits(), &vec![0, 2]);
+        assert_eq!(n.digits(), vec![0, 2]);
 
         n.increment().unwrap();
-        assert_eq!(n.digits(), &vec![1, 0]);
+        assert_eq!(n.digits(), vec![1, 0]);
 
         n.increment().unwrap();
-        assert_eq!(n.digits(), &vec![1, 1]);
+        assert_eq!(n.digits(), vec![1, 1]);
 
         n.increment().unwrap();
-        assert_eq!(n.digits(), &vec![1, 2]);
+        assert_eq!(n.digits(), vec![1, 2]);
 
         n.increment().unwrap();
-        assert_eq!(n.digits(), &vec![0, 0, 0]);
+        assert_eq!(n.digits(), vec![0, 0, 0]);
 
         n.increment().unwrap();
-        assert_eq!(n.digits(), &vec![0, 0, 1]);
+        assert_eq!(n.digits(), vec![0, 0, 1]);
     }
 
     #[test]
     fn test_dynamic_width_number_display_alphabetic() {
         fn num(n: usize) -> Number {
-            let mut number = Number::DynamicWidth(DynamicWidthNumber::new(26));
+            let mut number = Number::DynamicWidth(DynamicWidthNumber::new(26, 0));
             for _ in 0..n {
                 number.increment().unwrap();
             }
@@ -1042,7 +1006,7 @@
     #[test]
     fn test_dynamic_width_number_display_numeric_decimal() {
         fn num(n: usize) -> Number {
-            let mut number = Number::DynamicWidth(DynamicWidthNumber::new(10));
+            let mut number = Number::DynamicWidth(DynamicWidthNumber::new(10, 0));
             for _ in 0..n {
                 number.increment().unwrap();
             }
@@ -1063,7 +1027,7 @@
     #[test]
     fn test_dynamic_width_number_display_numeric_hexadecimal() {
         fn num(n: usize) -> Number {
-            let mut number = Number::DynamicWidth(DynamicWidthNumber::new(16));
+            let mut number = Number::DynamicWidth(DynamicWidthNumber::new(16, 0));
             for _ in 0..n {
                 number.increment().unwrap();
             }
@@ -1086,31 +1050,31 @@
 
     #[test]
     fn test_fixed_width_number_increment() {
-        let mut n = Number::FixedWidth(FixedWidthNumber::new(3, 2));
-        assert_eq!(n.digits(), &vec![0, 0]);
+        let mut n = Number::FixedWidth(FixedWidthNumber::new(3, 2, 0).unwrap());
+        assert_eq!(n.digits(), vec![0, 0]);
         n.increment().unwrap();
-        assert_eq!(n.digits(), &vec![0, 1]);
+        assert_eq!(n.digits(), vec![0, 1]);
         n.increment().unwrap();
-        assert_eq!(n.digits(), &vec![0, 2]);
+        assert_eq!(n.digits(), vec![0, 2]);
         n.increment().unwrap();
-        assert_eq!(n.digits(), &vec![1, 0]);
+        assert_eq!(n.digits(), vec![1, 0]);
         n.increment().unwrap();
-        assert_eq!(n.digits(), &vec![1, 1]);
+        assert_eq!(n.digits(), vec![1, 1]);
         n.increment().unwrap();
-        assert_eq!(n.digits(), &vec![1, 2]);
+        assert_eq!(n.digits(), vec![1, 2]);
         n.increment().unwrap();
-        assert_eq!(n.digits(), &vec![2, 0]);
+        assert_eq!(n.digits(), vec![2, 0]);
         n.increment().unwrap();
-        assert_eq!(n.digits(), &vec![2, 1]);
+        assert_eq!(n.digits(), vec![2, 1]);
         n.increment().unwrap();
-        assert_eq!(n.digits(), &vec![2, 2]);
+        assert_eq!(n.digits(), vec![2, 2]);
         assert!(n.increment().is_err());
     }
 
     #[test]
     fn test_fixed_width_number_display_alphabetic() {
         fn num(n: usize) -> Result<Number, Overflow> {
-            let mut number = Number::FixedWidth(FixedWidthNumber::new(26, 2));
+            let mut number = Number::FixedWidth(FixedWidthNumber::new(26, 2, 0).unwrap());
             for _ in 0..n {
                 number.increment()?;
             }
@@ -1135,7 +1099,7 @@
     #[test]
     fn test_fixed_width_number_display_numeric_decimal() {
         fn num(n: usize) -> Result<Number, Overflow> {
-            let mut number = Number::FixedWidth(FixedWidthNumber::new(10, 2));
+            let mut number = Number::FixedWidth(FixedWidthNumber::new(10, 2, 0).unwrap());
             for _ in 0..n {
                 number.increment()?;
             }
@@ -1154,7 +1118,7 @@
     #[test]
     fn test_fixed_width_number_display_numeric_hexadecimal() {
         fn num(n: usize) -> Result<Number, Overflow> {
-            let mut number = Number::FixedWidth(FixedWidthNumber::new(16, 2));
+            let mut number = Number::FixedWidth(FixedWidthNumber::new(16, 2, 0).unwrap());
             for _ in 0..n {
                 number.increment()?;
             }
@@ -1169,6 +1133,34 @@
         assert_eq!(format!("{}", num(16 * 16 - 1).unwrap()), "ff");
         assert!(num(16 * 16).is_err());
     }
+
+    #[test]
+    fn test_fixed_width_number_start_suffix() {
+        fn num(n: usize) -> Result<Number, Overflow> {
+            let mut number = Number::FixedWidth(FixedWidthNumber::new(16, 2, 0x14)?);
+            for _ in 0..n {
+                number.increment()?;
+            }
+            Ok(number)
+        }
+
+        assert_eq!(format!("{}", num(0).unwrap()), "14");
+        assert_eq!(format!("{}", num(0xf).unwrap()), "23");
+    }
+
+    #[test]
+    fn test_dynamic_width_number_start_suffix() {
+        fn num(n: usize) -> Result<Number, Overflow> {
+            let mut number = Number::DynamicWidth(DynamicWidthNumber::new(10, 8));
+            for _ in 0..n {
+                number.increment()?;
+            }
+            Ok(number)
+        }
+
+        assert_eq!(format!("{}", num(0).unwrap()), "08");
+        assert_eq!(format!("{}", num(8).unwrap()), "16");
+    }
 }
 
\ No newline at end of file diff --git a/dev/src/uu_split/split.rs.html b/dev/src/uu_split/split.rs.html index 45d61d702..18175044b 100644 --- a/dev/src/uu_split/split.rs.html +++ b/dev/src/uu_split/split.rs.html @@ -1365,6 +1365,23 @@ 1365 1366 1367 +1368 +1369 +1370 +1371 +1372 +1373 +1374 +1375 +1376 +1377 +1378 +1379 +1380 +1381 +1382 +1383 +1384
//  * This file is part of the uutils coreutils package.
 //  *
 //  * (c) Akira Hayakawa <ruby.wktk@gmail.com>
@@ -1511,7 +1528,7 @@
                 .takes_value(true)
                 .value_name("N")
                 .default_value(OPT_DEFAULT_SUFFIX_LENGTH)
-                .help("use suffixes of length N (default 2)"),
+                .help("use suffixes of fixed length N. 0 implies dynamic length."),
         )
         .arg(
             Arg::new(OPT_HEX_SUFFIXES)
@@ -1767,13 +1784,23 @@
 }
 
 /// Parse the suffix type from the command-line arguments.
-fn suffix_type_from(matches: &ArgMatches) -> SuffixType {
+fn suffix_type_from(matches: &ArgMatches) -> Result<(SuffixType, usize), SettingsError> {
     if matches.value_source(OPT_NUMERIC_SUFFIXES) == Some(ValueSource::CommandLine) {
-        SuffixType::Decimal
+        let suffix_start = matches.value_of(OPT_NUMERIC_SUFFIXES);
+        let suffix_start = suffix_start.ok_or(SettingsError::SuffixNotParsable(String::new()))?;
+        let suffix_start = suffix_start
+            .parse()
+            .map_err(|_| SettingsError::SuffixNotParsable(suffix_start.to_string()))?;
+        Ok((SuffixType::Decimal, suffix_start))
     } else if matches.value_source(OPT_HEX_SUFFIXES) == Some(ValueSource::CommandLine) {
-        SuffixType::Hexadecimal
+        let suffix_start = matches.value_of(OPT_HEX_SUFFIXES);
+        let suffix_start = suffix_start.ok_or(SettingsError::SuffixNotParsable(String::new()))?;
+        let suffix_start = usize::from_str_radix(suffix_start, 16)
+            .map_err(|_| SettingsError::SuffixNotParsable(suffix_start.to_string()))?;
+        Ok((SuffixType::Hexadecimal, suffix_start))
     } else {
-        SuffixType::Alphabetic
+        // no numeric/hex suffix
+        Ok((SuffixType::Alphabetic, 0))
     }
 }
 
@@ -1785,6 +1812,7 @@
     prefix: String,
     suffix_type: SuffixType,
     suffix_length: usize,
+    suffix_start: usize,
     additional_suffix: String,
     input: String,
     /// When supplied, a shell command to output to instead of xaa, xab …
@@ -1864,7 +1892,7 @@
             return Err(SettingsError::SuffixContainsSeparator(additional_suffix));
         }
         let strategy = Strategy::from(matches).map_err(SettingsError::Strategy)?;
-        let suffix_type = suffix_type_from(matches);
+        let (suffix_type, suffix_start) = suffix_type_from(matches)?;
         let suffix_length_str = matches.get_one::<String>(OPT_SUFFIX_LENGTH).unwrap();
         let suffix_length: usize = suffix_length_str
             .parse()
@@ -1884,6 +1912,7 @@
                 .parse()
                 .map_err(|_| SettingsError::SuffixNotParsable(suffix_length_str.to_string()))?,
             suffix_type,
+            suffix_start,
             additional_suffix,
             verbose: matches.value_source("verbose") == Some(ValueSource::CommandLine),
             strategy,
@@ -1956,7 +1985,8 @@
             &settings.additional_suffix,
             settings.suffix_length,
             settings.suffix_type,
-        );
+            settings.suffix_start,
+        )?;
         let filename = filename_iterator
             .next()
             .ok_or_else(|| USimpleError::new(1, "output file suffixes exhausted"))?;
@@ -2084,7 +2114,8 @@
             &settings.additional_suffix,
             settings.suffix_length,
             settings.suffix_type,
-        );
+            settings.suffix_start,
+        )?;
         let filename = filename_iterator
             .next()
             .ok_or_else(|| USimpleError::new(1, "output file suffixes exhausted"))?;
@@ -2192,7 +2223,8 @@
             &settings.additional_suffix,
             settings.suffix_length,
             settings.suffix_type,
-        );
+            settings.suffix_start,
+        )?;
         let filename = filename_iterator
             .next()
             .ok_or_else(|| USimpleError::new(1, "output file suffixes exhausted"))?;
@@ -2389,7 +2421,8 @@
         &settings.additional_suffix,
         settings.suffix_length,
         settings.suffix_type,
-    );
+        settings.suffix_start,
+    )?;
 
     // Create one writer for each chunk. This will create each
     // of the underlying files (if not in `--filter` mode).
@@ -2465,7 +2498,8 @@
         &settings.additional_suffix,
         settings.suffix_length,
         settings.suffix_type,
-    );
+        settings.suffix_start,
+    )?;
 
     // Create one writer for each chunk. This will create each
     // of the underlying files (if not in `--filter` mode).
diff --git a/dev/uu_cp/enum.Attribute.html b/dev/uu_cp/enum.Attribute.html
index 09c655245..f8e7ad4b6 100644
--- a/dev/uu_cp/enum.Attribute.html
+++ b/dev/uu_cp/enum.Attribute.html
@@ -1,30 +1,30 @@
-Attribute in uu_cp - Rust

Variants

Ownership

Mode

Timestamps

Context

Xattr

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

-

Formats the value using the given formatter. Read more

-

The associated error which can be returned from parsing.

-

Parses a string s to return a value of this type. Read more

-

This method returns an Ordering between self and other. Read more

+

Formats the value using the given formatter. Read more

+

The associated error which can be returned from parsing.

+

Parses a string s to return a value of this type. Read more

+

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

-

This method tests for self and other values to be equal, and is used +

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

-

This method returns an ordering between self and other values if one exists. Read more

+

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

-

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

+

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Compare self to key and return true if they are equal.

diff --git a/dev/uu_cp/enum.ClobberMode.html b/dev/uu_cp/enum.ClobberMode.html index c85daf2a3..770fd4b62 100644 --- a/dev/uu_cp/enum.ClobberMode.html +++ b/dev/uu_cp/enum.ClobberMode.html @@ -1,14 +1,14 @@ -ClobberMode in uu_cp - Rust
pub enum ClobberMode {
+ClobberMode in uu_cp - Rust
pub enum ClobberMode {
     Force,
     RemoveDestination,
     Standard,
 }
Expand description

Specifies whether when overwrite files

-

Variants

Force

RemoveDestination

Standard

Trait Implementations

Returns a copy of the value. Read more

+

Variants

Force

RemoveDestination

Standard

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

-

This method tests for self and other values to be equal, and is used +

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

-

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

+

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Compare self to key and return true if they are equal.

diff --git a/dev/uu_cp/enum.CopyMode.html b/dev/uu_cp/enum.CopyMode.html index b8bd12a36..226249b38 100644 --- a/dev/uu_cp/enum.CopyMode.html +++ b/dev/uu_cp/enum.CopyMode.html @@ -1,4 +1,4 @@ -CopyMode in uu_cp - Rust
pub enum CopyMode {
+CopyMode in uu_cp - Rust
pub enum CopyMode {
     Link,
     SymLink,
     Copy,
diff --git a/dev/uu_cp/enum.Error.html b/dev/uu_cp/enum.Error.html
index 8f1818fe5..6ff41c5f3 100644
--- a/dev/uu_cp/enum.Error.html
+++ b/dev/uu_cp/enum.Error.html
@@ -1,4 +1,4 @@
-Error in uu_cp - Rust
pub enum Error {
+Error in uu_cp - Rust
pub enum Error {
     IoErr(Error),
     IoErrContext(ErrorString),
     Error(String),
@@ -22,20 +22,20 @@ and not all files were copied.

path, but those that are not implemented yet should return a NotImplemented error.

Backup(String)

Invalid arguments to backup

-

Trait Implementations

Formats the value using the given formatter. Read more

-

Formats the value using the given formatter. Read more

-

The lower-level source of this error, if any. Read more

+

Trait Implementations

Formats the value using the given formatter. Read more

+

Formats the value using the given formatter. Read more

+

The lower-level source of this error, if any. Read more

👎 Deprecated since 1.42.0:

use the Display impl or to_string()

👎 Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

🔬 This is a nightly-only experimental API. (error_generic_member_access)

Provides type based access to context intended for error reports. Read more

-

Converts to this type from the input type.

-

Converts to this type from the input type.

-

Converts to this type from the input type.

-

Converts to this type from the input type.

-

Converts to this type from the input type.

-

Converts to this type from the input type.

-

Converts to this type from the input type.

-

Error code of a custom error. Read more

+

Converts to this type from the input type.

+

Converts to this type from the input type.

+

Converts to this type from the input type.

+

Converts to this type from the input type.

+

Converts to this type from the input type.

+

Converts to this type from the input type.

+

Converts to this type from the input type.

+

Error code of a custom error. Read more

Print usage help to a custom error. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Variants

Clobber(ClobberMode)

Default Always overwrite existing files

Interactive(ClobberMode)

Prompt before overwriting a file

NoClobber

Never overwrite a file

-

Trait Implementations

Returns a copy of the value. Read more

+

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

-

This method tests for self and other values to be equal, and is used +

This method tests for self and other values to be equal, and is used by ==. Read more

-

This method tests for !=.

-

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

+

This method tests for !=.

+

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Compare self to key and return true if they are equal.

diff --git a/dev/uu_cp/enum.ReflinkMode.html b/dev/uu_cp/enum.ReflinkMode.html index 9552d9af4..7c35f84dd 100644 --- a/dev/uu_cp/enum.ReflinkMode.html +++ b/dev/uu_cp/enum.ReflinkMode.html @@ -1,14 +1,14 @@ -ReflinkMode in uu_cp - Rust
pub enum ReflinkMode {
+ReflinkMode in uu_cp - Rust
pub enum ReflinkMode {
     Always,
     Auto,
     Never,
 }
Expand description

Possible arguments for --reflink.

-

Variants

Always

Auto

Never

Trait Implementations

Returns a copy of the value. Read more

+

Variants

Always

Auto

Never

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

-

This method tests for self and other values to be equal, and is used +

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

-

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

+

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Compare self to key and return true if they are equal.

diff --git a/dev/uu_cp/enum.SparseMode.html b/dev/uu_cp/enum.SparseMode.html index d246cea4a..27b7d5602 100644 --- a/dev/uu_cp/enum.SparseMode.html +++ b/dev/uu_cp/enum.SparseMode.html @@ -1,14 +1,14 @@ -SparseMode in uu_cp - Rust
pub enum SparseMode {
+SparseMode in uu_cp - Rust
pub enum SparseMode {
     Always,
     Auto,
     Never,
 }
Expand description

Possible arguments for --sparse.

-

Variants

Always

Auto

Never

Trait Implementations

Returns a copy of the value. Read more

+

Variants

Always

Auto

Never

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

-

This method tests for self and other values to be equal, and is used +

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

-

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

+

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Compare self to key and return true if they are equal.

diff --git a/dev/uu_cp/enum.TargetType.html b/dev/uu_cp/enum.TargetType.html index 659bac483..56a99eac9 100644 --- a/dev/uu_cp/enum.TargetType.html +++ b/dev/uu_cp/enum.TargetType.html @@ -1,4 +1,4 @@ -TargetType in uu_cp - Rust
pub enum TargetType {
+TargetType in uu_cp - Rust
pub enum TargetType {
     Directory,
     File,
 }
Expand description

Specifies the expected file type of copy target

diff --git a/dev/uu_cp/fn.localize_to_target.html b/dev/uu_cp/fn.localize_to_target.html index 6aea4b17e..fdcdb56af 100644 --- a/dev/uu_cp/fn.localize_to_target.html +++ b/dev/uu_cp/fn.localize_to_target.html @@ -1,4 +1,4 @@ -localize_to_target in uu_cp - Rust
pub fn localize_to_target(
    root: &Path,
    source: &Path,
    target: &Path
) -> CopyResult<PathBuf>
Expand description

Remove the root prefix from source and prefix it with target +localize_to_target in uu_cp - Rust

pub fn localize_to_target(
    root: &Path,
    source: &Path,
    target: &Path
) -> CopyResult<PathBuf>
Expand description

Remove the root prefix from source and prefix it with target to create a file that is local to target

Examples

assert!(uu_cp::localize_to_target(
diff --git a/dev/uu_cp/fn.path_has_prefix.html b/dev/uu_cp/fn.path_has_prefix.html
index f8858871c..75f2a7e88 100644
--- a/dev/uu_cp/fn.path_has_prefix.html
+++ b/dev/uu_cp/fn.path_has_prefix.html
@@ -1 +1 @@
-path_has_prefix in uu_cp - Rust
pub fn path_has_prefix(p1: &Path, p2: &Path) -> Result<bool>
\ No newline at end of file +path_has_prefix in uu_cp - Rust
pub fn path_has_prefix(p1: &Path, p2: &Path) -> Result<bool>
\ No newline at end of file diff --git a/dev/uu_cp/fn.uu_app.html b/dev/uu_cp/fn.uu_app.html index 78688adaa..208348592 100644 --- a/dev/uu_cp/fn.uu_app.html +++ b/dev/uu_cp/fn.uu_app.html @@ -1 +1 @@ -uu_app in uu_cp - Rust

Function uu_cp::uu_app

source · []
pub fn uu_app<'a>() -> Command<'a>
\ No newline at end of file +uu_app in uu_cp - Rust

Function uu_cp::uu_app

source · []
pub fn uu_app<'a>() -> Command<'a>
\ No newline at end of file diff --git a/dev/uu_cp/fn.uumain.html b/dev/uu_cp/fn.uumain.html index 82b1510f4..d05c0d310 100644 --- a/dev/uu_cp/fn.uumain.html +++ b/dev/uu_cp/fn.uumain.html @@ -1 +1 @@ -uumain in uu_cp - Rust

Function uu_cp::uumain

source · []
pub fn uumain(args: impl Args) -> i32
\ No newline at end of file +uumain in uu_cp - Rust

Function uu_cp::uumain

source · []
pub fn uumain(args: impl Args) -> i32
\ No newline at end of file diff --git a/dev/uu_cp/fn.verify_target_type.html b/dev/uu_cp/fn.verify_target_type.html index 0d0468b1a..84a9816a3 100644 --- a/dev/uu_cp/fn.verify_target_type.html +++ b/dev/uu_cp/fn.verify_target_type.html @@ -1,2 +1,2 @@ -verify_target_type in uu_cp - Rust
pub fn verify_target_type(
    target: &Path,
    target_type: &TargetType
) -> CopyResult<()>
Expand description

Generate an error message if target is not the correct target_type

+verify_target_type in uu_cp - Rust
pub fn verify_target_type(
    target: &Path,
    target_type: &TargetType
) -> CopyResult<()>
Expand description

Generate an error message if target is not the correct target_type

\ No newline at end of file diff --git a/dev/uu_cp/index.html b/dev/uu_cp/index.html index 2281e14c9..df5c40f3b 100644 --- a/dev/uu_cp/index.html +++ b/dev/uu_cp/index.html @@ -1,4 +1,4 @@ -uu_cp - Rust

Structs

Re-usable, extensible copy options

+uu_cp - Rust

Structs

Re-usable, extensible copy options

Enums

Specifies whether when overwrite files

Specifies whether when overwrite files

Possible arguments for --reflink.

diff --git a/dev/uu_cp/struct.Options.html b/dev/uu_cp/struct.Options.html index fe4de345d..18d42e8f4 100644 --- a/dev/uu_cp/struct.Options.html +++ b/dev/uu_cp/struct.Options.html @@ -1,4 +1,4 @@ -Options in uu_cp - Rust
pub struct Options { /* private fields */ }
Expand description

Re-usable, extensible copy options

+Options in uu_cp - Rust
pub struct Options { /* private fields */ }
Expand description

Re-usable, extensible copy options

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

diff --git a/dev/uu_cp/type.CopyResult.html b/dev/uu_cp/type.CopyResult.html index 659277153..f5bf5c2e0 100644 --- a/dev/uu_cp/type.CopyResult.html +++ b/dev/uu_cp/type.CopyResult.html @@ -1 +1 @@ -CopyResult in uu_cp - Rust

Type Definition uu_cp::CopyResult

source · []
pub type CopyResult<T> = Result<T, Error>;
\ No newline at end of file +CopyResult in uu_cp - Rust

Type Definition uu_cp::CopyResult

source · []
pub type CopyResult<T> = Result<T, Error>;
\ No newline at end of file diff --git a/dev/uu_cp/type.Source.html b/dev/uu_cp/type.Source.html index 9c932730b..c8cc96750 100644 --- a/dev/uu_cp/type.Source.html +++ b/dev/uu_cp/type.Source.html @@ -1 +1 @@ -Source in uu_cp - Rust

Type Definition uu_cp::Source

source · []
pub type Source = PathBuf;
\ No newline at end of file +Source in uu_cp - Rust

Type Definition uu_cp::Source

source · []
pub type Source = PathBuf;
\ No newline at end of file diff --git a/dev/uu_cp/type.SourceSlice.html b/dev/uu_cp/type.SourceSlice.html index 49e221611..38bc49586 100644 --- a/dev/uu_cp/type.SourceSlice.html +++ b/dev/uu_cp/type.SourceSlice.html @@ -1 +1 @@ -SourceSlice in uu_cp - Rust

Type Definition uu_cp::SourceSlice

source · []
pub type SourceSlice = Path;
\ No newline at end of file +SourceSlice in uu_cp - Rust

Type Definition uu_cp::SourceSlice

source · []
pub type SourceSlice = Path;
\ No newline at end of file diff --git a/dev/uu_cp/type.Target.html b/dev/uu_cp/type.Target.html index e9a7f11fa..dc6c8cfb6 100644 --- a/dev/uu_cp/type.Target.html +++ b/dev/uu_cp/type.Target.html @@ -1 +1 @@ -Target in uu_cp - Rust

Type Definition uu_cp::Target

source · []
pub type Target = PathBuf;
\ No newline at end of file +Target in uu_cp - Rust

Type Definition uu_cp::Target

source · []
pub type Target = PathBuf;
\ No newline at end of file diff --git a/dev/uu_cp/type.TargetSlice.html b/dev/uu_cp/type.TargetSlice.html index ecc252bb5..2e5bbd733 100644 --- a/dev/uu_cp/type.TargetSlice.html +++ b/dev/uu_cp/type.TargetSlice.html @@ -1 +1 @@ -TargetSlice in uu_cp - Rust

Type Definition uu_cp::TargetSlice

source · []
pub type TargetSlice = Path;
\ No newline at end of file +TargetSlice in uu_cp - Rust

Type Definition uu_cp::TargetSlice

source · []
pub type TargetSlice = Path;
\ No newline at end of file diff --git a/dev/uu_split/index.html b/dev/uu_split/index.html index 1be58dbf8..aa0f15ced 100644 --- a/dev/uu_split/index.html +++ b/dev/uu_split/index.html @@ -1 +1 @@ -uu_split - Rust
\ No newline at end of file +uu_split - Rust
\ No newline at end of file