Rohan Sircar
3 years ago
3 changed files with 69 additions and 30 deletions
-
41build.sbt
-
26src/main/scala/wow/doge/mygame/subsystems/moddingsystem/ModdingSystem.scala
-
32src/main/scala/wow/doge/mygame/utils/package.scala
@ -1,6 +1,38 @@ |
|||
package wow.doge.mygame |
|||
|
|||
import java.nio.file.StandardOpenOption |
|||
|
|||
import monix.bio.UIO |
|||
import monix.execution.Scheduler |
|||
import monix.nio.file.AsyncFileChannelConsumer |
|||
import monix.nio.text.UTF8Codec.utf8Decode |
|||
import monix.nio.{file => mnf} |
|||
import wow.doge.mygame.implicits._ |
|||
|
|||
package object utils { |
|||
def methodName(implicit enclosing: sourcecode.Enclosing) = |
|||
enclosing.value.split(" ")(0).split("""\.""").last |
|||
|
|||
def readAsync( |
|||
path: os.Path, |
|||
chunkSize: Int = 8192 |
|||
) = |
|||
UIO |
|||
.deferAction(implicit s => UIO(mnf.readAsync(path.toNIO, chunkSize))) |
|||
.flatMap(bytes => UIO(bytes.pipeThrough(utf8Decode))) |
|||
|
|||
@SuppressWarnings(Array("org.wartremover.warts.TraversableOps")) |
|||
def readAsyncL( |
|||
path: os.Path, |
|||
chunkSize: Int = 8192 |
|||
) = |
|||
readAsync(path, chunkSize) |
|||
.flatMap(_.toListL.toIO) |
|||
.map(_.head) |
|||
|
|||
def writeAsync(path: os.Path, flags: Seq[StandardOpenOption] = Seq.empty)( |
|||
implicit s: Scheduler |
|||
): AsyncFileChannelConsumer = |
|||
mnf.appendAsync(path.toNIO, 0, flags) |
|||
|
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue