@@ -10,8 +10,8 @@ object FileTypes:
1010 ):
1111 override def toString = underlying.toString
1212 def toPath : Path = underlying
13+ def / (s : String ): Path = underlying / s
1314
14- given Conversion [Directory , Path ] = _.underlying
1515 object Directory :
1616
1717 def fromPath (path : Path ): IO [Option [Directory ]] =
@@ -25,7 +25,10 @@ object FileTypes:
2525 def fromPathFailFast (path : Path ): IO [Directory ] =
2626 fromPath(path).flatMap {
2727 case Some (dir) => IO .pure(dir)
28- case None => IO .raiseError(new Exception (s " $path must be a directory! " ))
28+ case None =>
29+ IO .raiseError(
30+ new Exception (s " $path is either not a directory or does not exist! " )
31+ )
2932 }
3033
3134 def fromPathUnsafe (path : Path ): Directory = Directory (path)
@@ -40,8 +43,8 @@ object FileTypes:
4043 class File private [FileTypes ] (private [FileTypes ] val underlying : Path ):
4144 override def toString (): String = underlying.toString
4245 def toPath = underlying
46+ def extName = underlying.extName
4347
44- given Conversion [File , Path ] = _.underlying
4548 object File :
4649 def fromPath (path : Path ): IO [Option [File ]] =
4750 Files [IO ]
@@ -55,7 +58,11 @@ object FileTypes:
5558 fromPath(path).flatMap {
5659 case Some (file) => IO .pure(file)
5760 case None =>
58- IO .raiseError(new Exception (s " $path must be a regular file! " ))
61+ IO .raiseError(
62+ new Exception (
63+ s " $path is either not a regular file or does not exist! "
64+ )
65+ )
5966 }
6067
6168 def fromPathUnsafe (path : Path ): File = File (path)
0 commit comments