mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 00:45:18 +03:00
vfs: add VFS::read
Summary: Adding method to VFS to read file content Reviewed By: DurhamG Differential Revision: D27799146 fbshipit-source-id: c7e5c2dbd496d3cfd349a435225b1d44ee14cda0
This commit is contained in:
parent
a3eb6b227a
commit
82f93150a0
@ -28,6 +28,7 @@ use util::path::remove_file;
|
||||
|
||||
use crate::pathauditor::PathAuditor;
|
||||
|
||||
use minibytes::Bytes;
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -289,6 +290,13 @@ impl VFS {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Reads file content
|
||||
pub fn read(&self, path: &RepoPath) -> Result<Bytes> {
|
||||
let filepath = self.inner.auditor.audit(path)?;
|
||||
let content = std::fs::read(filepath)?;
|
||||
Ok(content.into())
|
||||
}
|
||||
|
||||
/// Removes file, but inlike Self::remove, does not delete empty directories.
|
||||
fn remove_keep_path(&self, filepath: &PathBuf) -> Result<()> {
|
||||
if let Ok(metadata) = symlink_metadata(&filepath) {
|
||||
|
Loading…
Reference in New Issue
Block a user