Steup CI (#1)
Some checks failed
Test Workflow / Lint and test library (push) Has been cancelled
Some checks failed
Test Workflow / Lint and test library (push) Has been cancelled
Setup Github actions CI to test and publish the library. Reviewed-on: #1
This commit is contained in:
@@ -8,7 +8,10 @@ import java.nio.file.Path
|
||||
class FSCreator {
|
||||
// Create entry, leaving existing folders' contents, but overwriting existing files.
|
||||
@Throws(FileSystemException::class)
|
||||
fun create(entryToCreate: FSEntry, destination: String) {
|
||||
fun create(
|
||||
entryToCreate: FSEntry,
|
||||
destination: String,
|
||||
) {
|
||||
val queue = ArrayDeque<Pair<FSEntry, Path>>()
|
||||
queue.add(entryToCreate to Path.of(destination))
|
||||
|
||||
@@ -20,7 +23,8 @@ class FSCreator {
|
||||
is FSFile -> Files.createFile(path)
|
||||
is FSFolder -> Files.createDirectory(path)
|
||||
}
|
||||
} catch (_: FileAlreadyExistsException) {} // Allow files/folders to already exist.
|
||||
} catch (_: FileAlreadyExistsException) {
|
||||
} // Allow files/folders to already exist.
|
||||
when (entry) {
|
||||
is FSFile -> Files.write(path, entry.content.toByteArray())
|
||||
is FSFolder -> queue.addAll(entry.entries.map { it to path })
|
||||
|
@@ -4,6 +4,6 @@ package filesystem
|
||||
// (as we expect), and it also makes the class abstract as required.
|
||||
sealed class FSEntry(val name: String)
|
||||
|
||||
class FSFile(name: String, val content: String): FSEntry(name)
|
||||
class FSFile(name: String, val content: String) : FSEntry(name)
|
||||
|
||||
class FSFolder(name: String, val entries: List<FSEntry>): FSEntry(name)
|
||||
class FSFolder(name: String, val entries: List<FSEntry>) : FSEntry(name)
|
Reference in New Issue
Block a user