A music player that connects to your cloud/distributed storage.
1module String.Path exposing (..)
2
3import List.Extra as List
4
5
6
7-- ⛩
8
9
10sep : String
11sep =
12 "/"
13
14
15
16-- 🔱
17
18
19addSuffix : String -> String
20addSuffix path =
21 case path of
22 "" ->
23 ""
24
25 p ->
26 p ++ sep
27
28
29{-| Drop an amount of path segments from the right side.
30
31 >>> dropRight 5 "a/b/c/d/e/f"
32 "a"
33
34-}
35dropRight : Int -> String -> String
36dropRight int path =
37 path
38 |> String.split sep
39 |> (\l -> List.take (List.length l - int) l)
40 |> String.join sep
41
42
43file : String -> String
44file path =
45 path
46 |> String.split sep
47 |> List.last
48 |> Maybe.withDefault path