diff src/clojure/contrib/classpath.clj @ 10:ef7dbbd6452c

added clojure source goodness
author Robert McIntyre <rlm@mit.edu>
date Sat, 21 Aug 2010 06:25:44 -0400
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/clojure/contrib/classpath.clj	Sat Aug 21 06:25:44 2010 -0400
     1.3 @@ -0,0 +1,39 @@
     1.4 +;;; classpath.clj: utilities for working with the Java class path
     1.5 +
     1.6 +;; by Stuart Sierra, http://stuartsierra.com/
     1.7 +;; April 19, 2009
     1.8 +
     1.9 +;; Copyright (c) Stuart Sierra, 2009. All rights reserved.  The use
    1.10 +;; and distribution terms for this software are covered by the Eclipse
    1.11 +;; Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
    1.12 +;; which can be found in the file epl-v10.html at the root of this
    1.13 +;; distribution.  By using this software in any fashion, you are
    1.14 +;; agreeing to be bound by the terms of this license.  You must not
    1.15 +;; remove this notice, or any other, from this software.
    1.16 +
    1.17 +
    1.18 +(ns 
    1.19 +  ^{:author "Stuart Sierra",
    1.20 +     :doc "Utilities for dealing with the JVM's classpath"}
    1.21 +  clojure.contrib.classpath
    1.22 +  (:require [clojure.contrib.jar :as jar])
    1.23 +  (:import (java.io File)
    1.24 +           (java.util.jar JarFile)))
    1.25 +
    1.26 +(defn classpath
    1.27 +  "Returns a sequence of File objects of the elements on CLASSPATH."
    1.28 +  []
    1.29 +  (map #(File. %)
    1.30 +       (.split (System/getProperty "java.class.path")
    1.31 +               (System/getProperty "path.separator"))))
    1.32 +
    1.33 +(defn classpath-directories
    1.34 +  "Returns a sequence of File objects for the directories on classpath."
    1.35 +  []
    1.36 +  (filter #(.isDirectory %) (classpath)))
    1.37 +
    1.38 +(defn classpath-jarfiles
    1.39 +  "Returns a sequence of JarFile objects for the JAR files on classpath."
    1.40 +  []
    1.41 +  (map #(JarFile. %) (filter jar/jar-file? (classpath))))
    1.42 +