import Foundation @testable import Peered final class InMemoryStorageProvider: StorageProvider { private(set) var files: [String: Data] = [:] func contentsOfDirectory(atPath path: String) throws -> [String] { return files.keys.compactMap { filePath -> String? in guard filePath.hasPrefix(path) else { return nil } let remainder = String(filePath.dropFirst(path.count)) let stripped = remainder.hasPrefix("/") ? String(remainder.dropFirst()) : remainder guard !stripped.isEmpty, !stripped.contains("/") else { return nil } return stripped } } @discardableResult func createFile( atPath path: String, contents data: Data?, attributes attr: [FileAttributeKey: Any]? ) -> Bool { files[path] = data ?? Data() return true } }