Skip to content

Commit 1183a12

Browse files
committed
formatting
1 parent ff46f85 commit 1183a12

File tree

6 files changed

+164
-164
lines changed

6 files changed

+164
-164
lines changed

Sources/WASI/FileSystem.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ enum FdEntry {
8383
return directory
8484
}
8585
}
86-
86+
8787
func asFile() -> (any WASIFile)? {
8888
if case .file(let entry) = self {
8989
return entry
@@ -140,16 +140,16 @@ public enum FileContent {
140140
public protocol FileSystemProvider {
141141
/// Adds a file to the file system with the given byte content.
142142
func addFile(at path: String, content: [UInt8]) throws
143-
143+
144144
/// Adds a file to the file system with the given string content.
145145
func addFile(at path: String, content: String) throws
146-
146+
147147
/// Adds a file to the file system backed by a file descriptor handle.
148148
func addFile(at path: String, handle: FileDescriptor) throws
149-
149+
150150
/// Gets the content of a file at the specified path.
151151
func getFile(at path: String) throws -> FileContent
152-
152+
153153
/// Removes a file from the file system.
154154
func removeFile(at path: String) throws
155155
}
@@ -161,10 +161,10 @@ public protocol FileSystemProvider {
161161
internal protocol FileSystem {
162162
/// Returns the list of pre-opened directory paths.
163163
func getPreopenPaths() -> [String]
164-
164+
165165
/// Opens a directory and returns a WASIDir implementation.
166166
func openDirectory(at path: String) throws -> any WASIDir
167-
167+
168168
/// Opens a file or directory from a directory file descriptor.
169169
func openAt(
170170
dirFd: any WASIDir,
@@ -175,7 +175,7 @@ internal protocol FileSystem {
175175
fdflags: WASIAbi.Fdflags,
176176
symlinkFollow: Bool
177177
) throws -> FdEntry
178-
178+
179179
/// Creates a standard I/O file entry for stdin/stdout/stderr.
180180
func createStdioFile(fd: FileDescriptor, accessMode: FileAccessMode) -> any WASIFile
181-
}
181+
}

Sources/WASI/MemoryFileSystem/MemoryDirEntry.swift

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,40 @@ internal struct MemoryDirEntry: WASIDir {
66
let dirNode: MemoryDirectoryNode
77
let path: String
88
let fileSystem: MemoryFileSystem
9-
9+
1010
func attributes() throws -> WASIAbi.Filestat {
1111
return WASIAbi.Filestat(
1212
dev: 0, ino: 0, filetype: .DIRECTORY,
1313
nlink: 1, size: 0,
1414
atim: 0, mtim: 0, ctim: 0
1515
)
1616
}
17-
17+
1818
func fileType() throws -> WASIAbi.FileType {
1919
return .DIRECTORY
2020
}
21-
21+
2222
func status() throws -> WASIAbi.Fdflags {
2323
return []
2424
}
25-
25+
2626
func setTimes(
2727
atim: WASIAbi.Timestamp, mtim: WASIAbi.Timestamp,
2828
fstFlags: WASIAbi.FstFlags
2929
) throws {
3030
// No-op for memory filesystem - timestamps not tracked
3131
}
32-
32+
3333
func advise(
3434
offset: WASIAbi.FileSize, length: WASIAbi.FileSize, advice: WASIAbi.Advice
3535
) throws {
3636
// No-op for memory filesystem
3737
}
38-
38+
3939
func close() throws {
4040
// No-op for memory filesystem - no resources to release
4141
}
42-
42+
4343
func openFile(
4444
symlinkFollow: Bool,
4545
path: String,
@@ -51,39 +51,39 @@ internal struct MemoryDirEntry: WASIDir {
5151
// File opening is handled through the WASI bridge's path_open implementation
5252
throw WASIAbi.Errno.ENOTSUP
5353
}
54-
54+
5555
func createDirectory(atPath path: String) throws {
5656
let fullPath = self.path.hasSuffix("/") ? self.path + path : self.path + "/" + path
5757
try fileSystem.ensureDirectory(at: fullPath)
5858
}
59-
59+
6060
func removeDirectory(atPath path: String) throws {
6161
try fileSystem.removeNode(in: dirNode, at: path, mustBeDirectory: true)
6262
}
63-
63+
6464
func removeFile(atPath path: String) throws {
6565
try fileSystem.removeNode(in: dirNode, at: path, mustBeDirectory: false)
6666
}
67-
67+
6868
func symlink(from sourcePath: String, to destPath: String) throws {
6969
// Symlinks not supported in memory filesystem
7070
throw WASIAbi.Errno.ENOTSUP
7171
}
72-
72+
7373
func rename(from sourcePath: String, toDir newDir: any WASIDir, to destPath: String) throws {
7474
guard let newMemoryDir = newDir as? MemoryDirEntry else {
7575
throw WASIAbi.Errno.EXDEV
7676
}
77-
77+
7878
try fileSystem.rename(
7979
from: sourcePath, in: dirNode,
8080
to: destPath, in: newMemoryDir.dirNode
8181
)
8282
}
83-
83+
8484
func readEntries(cookie: WASIAbi.DirCookie) throws -> AnyIterator<Result<ReaddirElement, any Error>> {
8585
let children = dirNode.listChildren()
86-
86+
8787
let iterator = children.enumerated()
8888
.dropFirst(Int(cookie))
8989
.map { (index, name) -> Result<ReaddirElement, any Error> in
@@ -92,38 +92,38 @@ internal struct MemoryDirEntry: WASIDir {
9292
guard let childNode = fileSystem.lookup(at: childPath) else {
9393
throw WASIAbi.Errno.ENOENT
9494
}
95-
95+
9696
let fileType: WASIAbi.FileType
9797
switch childNode.type {
9898
case .directory: fileType = .DIRECTORY
9999
case .file: fileType = .REGULAR_FILE
100100
case .characterDevice: fileType = .CHARACTER_DEVICE
101101
}
102-
102+
103103
let dirent = WASIAbi.Dirent(
104104
dNext: WASIAbi.DirCookie(index + 1),
105105
dIno: 0,
106106
dirNameLen: WASIAbi.DirNameLen(name.utf8.count),
107107
dType: fileType
108108
)
109-
109+
110110
return (dirent, name)
111111
})
112112
}
113113
.makeIterator()
114-
114+
115115
return AnyIterator(iterator)
116116
}
117-
117+
118118
func attributes(path: String, symlinkFollow: Bool) throws -> WASIAbi.Filestat {
119119
let fullPath = self.path.hasSuffix("/") ? self.path + path : self.path + "/" + path
120120
guard let node = fileSystem.lookup(at: fullPath) else {
121121
throw WASIAbi.Errno.ENOENT
122122
}
123-
123+
124124
let fileType: WASIAbi.FileType
125125
var size: WASIAbi.FileSize = 0
126-
126+
127127
switch node.type {
128128
case .directory:
129129
fileType = .DIRECTORY
@@ -135,19 +135,19 @@ internal struct MemoryDirEntry: WASIDir {
135135
case .characterDevice:
136136
fileType = .CHARACTER_DEVICE
137137
}
138-
138+
139139
return WASIAbi.Filestat(
140140
dev: 0, ino: 0, filetype: fileType,
141141
nlink: 1, size: size,
142142
atim: 0, mtim: 0, ctim: 0
143143
)
144144
}
145-
145+
146146
func setFilestatTimes(
147147
path: String,
148148
atim: WASIAbi.Timestamp, mtim: WASIAbi.Timestamp,
149149
fstFlags: WASIAbi.FstFlags, symlinkFollow: Bool
150150
) throws {
151151
// No-op for memory filesystem - timestamps not tracked
152152
}
153-
}
153+
}

0 commit comments

Comments
 (0)