Permalink
Browse files

Merge pull request #44 from nauhygon/master

Fix issue #37: make misaki work on Windows
  • Loading branch information...
liquidz committed Dec 10, 2014
2 parents 8fb2117 + c5e97ef commit b8104e632058e3b3da4487513d10e666e5914ec9
Showing with 19 additions and 3 deletions.
  1. +1 −1 src/misaki/compiler/default/config.clj
  2. +2 −2 src/misaki/config.clj
  3. +16 −0 src/misaki/util/file.clj
@@ -61,7 +61,7 @@
"Check whether file is layout file or not."
[#^File file]
{:pre [(file? file)]}
- (str-contains? (.getAbsolutePath file) (:layout-dir *config*)))
+ (str-contains? (file-abspath file) (:layout-dir *config*)))
;; ## Converter
View
@@ -136,7 +136,7 @@
"Check whether file is post file or not."
[#^File file]
{:pre [(file? file)]}
- (and (:post-dir *config*) (str-contains? (.getAbsolutePath file)
+ (and (:post-dir *config*) (str-contains? (file-abspath file)
(:post-dir *config*))))
; =index-file?
@@ -208,7 +208,7 @@
(defn- make-regular-output-filename
"Make regular output filename from java.io.File."
[#^File file]
- (let [path (.getPath file)
+ (let [path (file-path file)
len (count (:template-dir *config*))]
(if (.startsWith path (:template-dir *config*))
(.substring path len)
View
@@ -12,6 +12,12 @@
[x]
(= java.io.File (class x)))
+; =normalize-slashes
+(defn normalize-slashes
+ "Replace backslashes to forward slashes."
+ [path]
+ (str/replace path #"[\\]+" "/"))
+
; =normalize-path
(defn normalize-path
"Normalize file path.
@@ -30,6 +36,16 @@
string? (keyword (last (str/split ext #"\*\.")))
nil)))
+(defn file-path
+ "Get the path of a file and normalize its slashes."
+ [#^File file]
+ (normalize-slashes (.getPath file)))
+
+(defn file-abspath
+ "Get the absolute path of a file and normalize its slashes."
+ [#^File file]
+ (normalize-slashes (.getAbsolutePath file)))
+
; =path
(defn path
"Combine paths."

0 comments on commit b8104e6

Please sign in to comment.