Back

as-file (clj)

(source)

protocol

(as-file x)
Coerce argument to a file.

Examples

defold/defold
(ns integration.atlas-test
  (:require [clojure.java.io :as io]
            [clojure.test :refer :all]
            [dynamo.graph :as g]
            [editor.atlas :as atlas]
            [editor.defold-project :as project]
            [editor.fs :as fs]
            [editor.workspace :as workspace]
            [integration.test-util :as test-util]
            [support.test-support :as test-support]))

(deftest sprite-trim-mode-image-io-error
  (test-support/with-clean-system
    (let [workspace (test-util/setup-scratch-workspace! world "test/resources/image_project")
          project (test-util/setup-project! workspace)
          atlas (project/get-resource-node project "/main/main.atlas")
          atlas-image (:node-id (test-util/outline atlas [0]))
          image-file (io/as-file (g/node-value atlas-image :image))
          image-bytes (fs/read-bytes image-file)
          layout-data-generator (g/node-value atlas :layout-data-generator)
          packed-page-images-generator (g/node-value atlas :packed-page-images-generator)
          call-generator #'atlas/call-generator]
defold/defold
(ns integration.asset-browser-test
  (:require [clojure.java.io :as io]
            [clojure.string :as string]
            [clojure.test :refer :all]
            [dynamo.graph :as g]
            [editor.asset-browser :as asset-browser]
            [editor.defold-project :as project]
            [editor.dialogs :as dialogs]
            [editor.fs :as fs]
            [editor.protobuf :as protobuf]
            [editor.resource :as resource]
            [editor.resource-watch :as resource-watch]
            [editor.workspace :as workspace]
            [integration.test-util :as test-util]
            [support.test-support :refer [with-clean-system]])
  (:import [com.defold.editor.test TestDdf$DefaultValue]))

(deftest drop-move
  (with-clean-system
    (let [workspace (test-util/setup-scratch-workspace! world)
          root-dir (workspace/project-path workspace)
          make-file (partial io/file root-dir)
          resource-map (g/node-value workspace :resource-map)]
      (testing "drag-moving game.project becomes copy"
        ;; moving /game.project and /car/car.script into the /collection directory
        (let [moved (asset-browser/drop-files! workspace [[(io/as-file (resource-map "/game.project")) (make-file "collection/game.project")]
                                                          [(io/as-file (resource-map "/car/car.script")) (make-file "collection/car.script")]]
                                               :move)]
          (workspace/resource-sync! workspace moved)
          (let [resource-map (g/node-value workspace :resource-map)]
            (is (some? (resource-map "/game.project")))
            (is (some? (resource-map "/collection/game.project")))
            (is (not (some? (resource-map "/car/car.script"))))
            (is (some? (resource-map "/collection/car.script")))))))))
jonase/eastwood
(ns testcases.unusednss3
  (:require [clojure.core.protocols :as protocols]
            [clojure.core.reducers  :as reducers]
            [clojure.data           :as data]
            [clojure.java.io        :as io]
            [clojure.reflect        :as reflect]))

(deftype Foo [whatever]
  io/Coercions
  (as-file [x] nil)
  (as-url  [x] nil))
immutant/immutant
(ns immutant.web.ssl-test
  (:require [clojure.test :refer :all]
            [clojure.java.io :as io]
            [immutant.web.ssl])
  (:import [java.security KeyStore]))

(deftest keystore-as-file
  (is (instance? KeyStore (load-keystore (io/file "dev-resources/keystore.jks") "password"))))
mikera/imagez
(ns mikera.image.protocols
  (:require [clojure.java.io :refer [as-file file]])
  (:import java.io.File
           java.io.InputStream
           java.net.URI
           java.net.URL
           javax.imageio.ImageIO
           java.awt.image.BufferedImage))

(extend-protocol ImageResource
  String
  (as-image [s] (ImageIO/read (as-file s)))