Skip to content

Commit

Permalink
Tweak code
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Feb 27, 2024
1 parent e001391 commit a090fc2
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/core/watch.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,25 @@ case class InotifyError()
extends Error(msg"the limit on the number of paths that can be watched has been exceeded")

extension [DirectoryType: SpecificDirectory: GenericDirectory](dirs: Seq[DirectoryType])(using Monitor)
def watch()(using Log[Text], GenericWatchService[DirectoryType], Raises[InotifyError]): Watcher[DirectoryType] =
def watch()(using Log[Text], GenericWatchService[DirectoryType]): Watcher[DirectoryType] raises InotifyError =
Watcher[DirectoryType](dirs*)

extension [DirectoryType: SpecificDirectory: GenericDirectory](dir: DirectoryType)(using Monitor)
def watch()(using Log[Text], GenericWatchService[DirectoryType], Raises[InotifyError]): Watcher[DirectoryType] =
def watch()(using Log[Text], GenericWatchService[DirectoryType]): Watcher[DirectoryType] raises InotifyError =
Watcher[DirectoryType](dir)

object Watcher:
def apply
[DirectoryType: GenericWatchService: SpecificDirectory: GenericDirectory]
def apply[DirectoryType: GenericWatchService: SpecificDirectory: GenericDirectory]
(dirs: DirectoryType*)(using Log[Text], Monitor)
: Watcher[DirectoryType] =
: Watcher[DirectoryType] =

val svc: jnf.WatchService = summon[GenericWatchService[DirectoryType]]()
val watcher = Watcher[DirectoryType](svc)
dirs.each(watcher.add(_))

watcher

case class Watcher
[DirectoryType: GenericDirectory: SpecificDirectory]
(private val svc: jnf.WatchService)
case class Watcher[DirectoryType: GenericDirectory: SpecificDirectory](private val svc: jnf.WatchService)
(using Monitor):

private val watches: HashMap[jnf.WatchKey, jnf.Path] = HashMap()
Expand Down

0 comments on commit a090fc2

Please sign in to comment.