From 67b52a441b98f4699688fe21e49178794a6feeeb Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 25 Feb 2014 16:09:50 -0400 Subject: more DAV url fixes for windows --- Remote/WebDAV/DavUrl.hs | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Remote/WebDAV/DavUrl.hs (limited to 'Remote/WebDAV') diff --git a/Remote/WebDAV/DavUrl.hs b/Remote/WebDAV/DavUrl.hs new file mode 100644 index 000000000..4862c4f37 --- /dev/null +++ b/Remote/WebDAV/DavUrl.hs @@ -0,0 +1,44 @@ +{- WebDAV urls. + - + - Copyright 2014 Joey Hess + - + - Licensed under the GNU GPL version 3 or higher. + -} + +{-# LANGUAGE CPP #-} + +module Remote.WebDAV.DavUrl where + +import Types +import Locations + +import Network.URI (normalizePathSegments) +import System.FilePath.Posix +#ifdef mingw32_HOST_OS +import Data.String.Utils +#endif + +type DavUrl = String + +{- The directory where files(s) for a key are stored. -} +davLocation :: DavUrl -> Key -> DavUrl +davLocation baseurl k = addTrailingPathSeparator $ + davUrl baseurl $ hashdir keyFile k + where +#ifndef mingw32_HOST_OS + hashdir = hashDirLower k +#else + hashdir = replace "\\" "/" (hashDirLower k) +#endif + +{- Where we store temporary data for a key as it's being uploaded. -} +tmpLocation :: DavUrl -> Key -> DavUrl +tmpLocation baseurl k = addTrailingPathSeparator $ + davUrl baseurl $ "tmp" keyFile k + +davUrl :: DavUrl -> FilePath -> DavUrl +davUrl baseurl file = baseurl file + +urlParent :: DavUrl -> DavUrl +urlParent url = dropTrailingPathSeparator $ + normalizePathSegments (dropTrailingPathSeparator url ++ "/..") -- cgit v1.2.3