mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-16 10:51:55 -04:00
Ignoring files in real file system when generating buffered filesystem with invalid chars in their names, should fix #758.
This commit is contained in:
parent
177617a176
commit
6c63956b2f
@ -14,6 +14,8 @@ trait Buffered extends OutputStreamFileSystem {
|
||||
|
||||
private val deletions = mutable.Map.empty[String, Long]
|
||||
|
||||
protected def isValidFilename(name: String) = true
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
override def delete(path: String) = {
|
||||
@ -37,7 +39,7 @@ trait Buffered extends OutputStreamFileSystem {
|
||||
override def load(nbt: NBTTagCompound) = {
|
||||
def recurse(path: String, directory: io.File) {
|
||||
makeDirectory(path)
|
||||
for (child <- directory.listFiles()) {
|
||||
for (child <- directory.listFiles() if isValidFilename(child.getName)) {
|
||||
val childPath = path + child.getName
|
||||
val childFile = new io.File(directory, child.getName)
|
||||
if (child.isDirectory) {
|
||||
|
@ -158,6 +158,8 @@ object FileSystem extends api.detail.FileSystemAPI {
|
||||
// accordingly before the path is passed to the file system.
|
||||
private val invalidChars = """\:*?"<>|""".toSet
|
||||
|
||||
override protected def isValidFilename(name: String) = !name.exists(invalidChars.contains)
|
||||
|
||||
override def makeDirectory(path: String) = super.makeDirectory(validatePath(path))
|
||||
|
||||
override protected def openOutputHandle(id: Int, path: String, mode: Mode) = super.openOutputHandle(id, validatePath(path), mode)
|
||||
@ -168,7 +170,7 @@ object FileSystem extends api.detail.FileSystemAPI {
|
||||
}
|
||||
|
||||
private def validatePath(path: String) = {
|
||||
if (path.exists(invalidChars.contains)) {
|
||||
if (!isValidFilename(path)) {
|
||||
throw new java.io.IOException("path contains invalid characters")
|
||||
}
|
||||
path
|
||||
|
Loading…
x
Reference in New Issue
Block a user