Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dir source for windows #389

Merged
merged 2 commits into from Oct 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Expand Up @@ -21,6 +21,8 @@ matrix:
name: minimal-versions
script:
- cargo -Z minimal-versions build --verbose
- rust: nightly
os: windows

script:
- cargo $TASK --verbose
Expand Down
7 changes: 5 additions & 2 deletions src/registry.rs
Expand Up @@ -18,6 +18,8 @@ use crate::render::{RenderContext, Renderable};
use crate::support::str::{self, StringWriter};
use crate::template::Template;

#[cfg(feature = "dir_source")]
use std::path;
#[cfg(feature = "dir_source")]
use walkdir::{DirEntry, WalkDir};

Expand Down Expand Up @@ -242,7 +244,7 @@ impl<'reg> Registry<'reg> {
{
let dir_path = dir_path.as_ref();

let prefix_len = if dir_path.to_string_lossy().ends_with('/') {
let prefix_len = if dir_path.to_string_lossy().ends_with(path::MAIN_SEPARATOR) {
dir_path.to_string_lossy().len()
} else {
dir_path.to_string_lossy().len() + 1
Expand All @@ -261,7 +263,8 @@ impl<'reg> Registry<'reg> {
let tpl_file_path = entry.path().to_string_lossy();

let tpl_name = &tpl_file_path[prefix_len..tpl_file_path.len() - tpl_extension.len()];
let tpl_canonical_name = tpl_name.replace("\\", "/");
// replace platform path separator with our internal one
let tpl_canonical_name = tpl_name.replace(path::MAIN_SEPARATOR, "/");
self.register_template_file(&tpl_canonical_name, &tpl_path)?;
}

Expand Down