@@ -67,6 +67,12 @@ public struct FileSystemError: Error, Equatable {
67
67
/// This is thrown when copying or moving a file or directory but the destination
68
68
/// path already contains a file or folder.
69
69
case alreadyExistsAtDestination
70
+
71
+ /// If an unspecified error occurs when trying to change directories.
72
+ case couldNotChangeDirectory
73
+
74
+ /// If a mismatch is detected in byte count when writing to a file.
75
+ case mismatchedByteCount( expected: Int , actual: Int )
70
76
}
71
77
72
78
/// The kind of the error being raised.
@@ -99,7 +105,7 @@ public extension FileSystemError {
99
105
case TSCLibc . ENOTDIR:
100
106
self . init ( . notDirectory, path)
101
107
default :
102
- self . init ( . unknownOSError , path)
108
+ self . init ( . ioError ( code : errno ) , path)
103
109
}
104
110
}
105
111
}
@@ -343,7 +349,7 @@ private class LocalFileSystem: FileSystem {
343
349
}
344
350
345
351
guard FileManager . default. changeCurrentDirectoryPath ( path. pathString) else {
346
- throw FileSystemError ( . unknownOSError , path)
352
+ throw FileSystemError ( . couldNotChangeDirectory , path)
347
353
}
348
354
}
349
355
@@ -440,7 +446,7 @@ private class LocalFileSystem: FileSystem {
440
446
throw FileSystemError ( . ioError( code: errno) , path)
441
447
}
442
448
if n != contents. count {
443
- throw FileSystemError ( . unknownOSError , path)
449
+ throw FileSystemError ( . mismatchedByteCount ( expected : contents . count , actual : n ) , path)
444
450
}
445
451
break
446
452
}
0 commit comments