This repository has been archived by the owner on Mar 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
29 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
use anyhow::{anyhow, Result}; | ||
use std::path::PathBuf; | ||
use std::path::{Path, PathBuf}; | ||
|
||
const HOCUS_DIR_NAME: &str = ".hocus"; | ||
const GENERATED_DIR_NAME: &str = ".generated"; | ||
|
||
pub fn get_app_dir() -> Result<PathBuf> { | ||
let dir = dirs::home_dir().ok_or(anyhow!("failed to get the path to the home directory"))?; | ||
Ok(dir.join(HOCUS_DIR_NAME)) | ||
} | ||
|
||
pub fn get_project_dir(project_name: &str) -> Result<PathBuf> { | ||
let hocus_dir = get_app_dir()?; | ||
Ok(hocus_dir.join(project_name)) | ||
} | ||
|
||
pub fn get_generated_dir(project_dir: &Path) -> PathBuf { | ||
project_dir.join(GENERATED_DIR_NAME) | ||
} |