GitRoot
craft your forge, build your project, grow your community freely
1// SPDX-FileCopyrightText: 2025 Romain Maneschi <romain@gitroot.dev>
2//
3// SPDX-License-Identifier: MIT
4
5use std::{fs, io};
6
7pub struct Fs {
8 start: String,
9}
10
11impl Fs {
12 pub fn new(start: String) -> Self {
13 Fs { start: start }
14 }
15
16 pub fn open(&self, path: String) -> Result<String, io::Error> {
17 let prepend = &self.start;
18 fs::read_to_string(format!("{prepend}/{path}"))
19 }
20
21 pub fn exists(&self, path: String) -> Result<bool, io::Error> {
22 let prepend = &self.start;
23 fs::exists(format!("{prepend}/{path}"))
24 }
25}