comparison rust/hg-core/src/utils/files.rs @ 48082:789475ef2b22

rust: remove dead code Differential Revision: https://phab.mercurial-scm.org/D11549
author Raphaël Gomès <rgomes@octobus.net>
date Fri, 01 Oct 2021 18:14:56 +0200
parents be579775c2d9
children e98fd81bb151
comparison
equal deleted inserted replaced
48079:3da7bf75fdb2 48082:789475ef2b22
16 }; 16 };
17 use lazy_static::lazy_static; 17 use lazy_static::lazy_static;
18 use same_file::is_same_file; 18 use same_file::is_same_file;
19 use std::borrow::{Cow, ToOwned}; 19 use std::borrow::{Cow, ToOwned};
20 use std::ffi::{OsStr, OsString}; 20 use std::ffi::{OsStr, OsString};
21 use std::fs::Metadata;
22 use std::iter::FusedIterator; 21 use std::iter::FusedIterator;
23 use std::ops::Deref; 22 use std::ops::Deref;
24 use std::path::{Path, PathBuf}; 23 use std::path::{Path, PathBuf};
25 24
26 pub fn get_os_str_from_bytes(bytes: &[u8]) -> &OsStr { 25 pub fn get_os_str_from_bytes(bytes: &[u8]) -> &OsStr {
177 } 176 }
178 } 177 }
179 178
180 pub fn lower_clean(bytes: &[u8]) -> Vec<u8> { 179 pub fn lower_clean(bytes: &[u8]) -> Vec<u8> {
181 hfs_ignore_clean(&bytes.to_ascii_lowercase()) 180 hfs_ignore_clean(&bytes.to_ascii_lowercase())
182 }
183
184 #[derive(Eq, PartialEq, Ord, PartialOrd, Copy, Clone)]
185 pub struct HgMetadata {
186 pub st_dev: u64,
187 pub st_mode: u32,
188 pub st_nlink: u64,
189 pub st_size: u64,
190 pub st_mtime: i64,
191 pub st_ctime: i64,
192 }
193
194 // TODO support other plaforms
195 #[cfg(unix)]
196 impl HgMetadata {
197 pub fn from_metadata(metadata: Metadata) -> Self {
198 use std::os::unix::fs::MetadataExt;
199 Self {
200 st_dev: metadata.dev(),
201 st_mode: metadata.mode(),
202 st_nlink: metadata.nlink(),
203 st_size: metadata.size(),
204 st_mtime: metadata.mtime(),
205 st_ctime: metadata.ctime(),
206 }
207 }
208
209 pub fn is_symlink(&self) -> bool {
210 // This is way too manual, but `HgMetadata` will go away in the
211 // near-future dirstate rewrite anyway.
212 self.st_mode & 0170000 == 0120000
213 }
214 } 181 }
215 182
216 /// Returns the canonical path of `name`, given `cwd` and `root` 183 /// Returns the canonical path of `name`, given `cwd` and `root`
217 pub fn canonical_path( 184 pub fn canonical_path(
218 root: impl AsRef<Path>, 185 root: impl AsRef<Path>,