Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,13 +393,14 @@ pub fn make_symlink_or_file(target: &Path, link: &Path) -> Result<()> {
}

pub fn resolve_symlink(link: &Path) -> Result<Option<PathBuf>> {
if !link.is_symlink() {
return Ok(None);
}
if cfg!(windows) {
// Windows symlink are write in file currently
// may be changed to symlink in the future
if link.is_symlink() {
Ok(Some(fs::read_link(link)?))
} else if link.is_file() {
Ok(Some(fs::read_to_string(link)?.into()))
} else {
Ok(Some(fs::read_link(link)?))
Ok(None)
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/runtime_symlinks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,11 @@ pub fn remove_missing_symlinks(backend: Arc<dyn Backend>) -> Result<()> {
Ok(())
}

// for unix/linux ./1.1.1
// for Windows .\1.1.1
pub fn is_runtime_symlink(path: &Path) -> bool {
if let Ok(Some(link)) = file::resolve_symlink(path) {
return link.starts_with("./");
return link.starts_with(format!(".{}", std::path::MAIN_SEPARATOR_STR));
Comment thread
qianlongzt marked this conversation as resolved.
Outdated
}
false
}
Loading