Permalink
Browse files

Eliminate reflection.

Conflicts:

	src/swank/util/sys.clj
  • Loading branch information...
1 parent 9507401 commit 7c46f64d487588b28435b68922c6287e9a9bfde9 @technomancy committed Mar 24, 2012
Showing with 23 additions and 1 deletion.
  1. +1 −1 src/swank/swank.clj
  2. +22 −0 src/swank/util/sys.clj
View
@@ -82,7 +82,7 @@
(reset! shutting-down? true)
(doseq [c @connections]
(doseq [t [:control-thread :read-thread :repl-thread]]
- (when-let [thread @(c t)]
+ (when-let [^Thread thread @(c t)]
(.interrupt thread))))
(close-server-socket! @current-server)
(dosync (ref-set connections []))
View
@@ -9,5 +9,27 @@
(System/getProperty "pid")))
{:tag String})
+(defn #^java.lang.Process cmd [p]
+ (.. Runtime getRuntime (exec (str p))))
+
+(defn cmdout [^Process o]
+ (let [r (BufferedReader.
+ (InputStreamReader. (.getInputStream o)))]
+ (line-seq r)))
+
+;; would prefer (= (System/getenv "OSTYPE") "cygwin")
+;; but clojure's java not in cygwin env
+(defn is-cygwin? []
+ (not= nil (try (cmdout (cmd "cygpath c:\\")) (catch Exception e))))
+
+(defn universal-path [path]
+ (if (is-cygwin?)
+ (first (cmdout (cmd (str "cygpath " path))))
+ path))
+
+(defn preferred-user-home-path []
+ (or (System/getenv "HOME")
+ (System/getProperty "user.home")))
+
(defn user-home-path []
(System/getProperty "user.home"))

0 comments on commit 7c46f64

Please sign in to comment.