@@ -67,6 +67,12 @@ public struct FileSystemError: Error, Equatable {
6767 /// This is thrown when copying or moving a file or directory but the destination
6868 /// path already contains a file or folder.
6969 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 )
7076 }
7177
7278 /// The kind of the error being raised.
@@ -99,7 +105,7 @@ public extension FileSystemError {
99105 case TSCLibc . ENOTDIR:
100106 self . init ( . notDirectory, path)
101107 default :
102- self . init ( . unknownOSError , path)
108+ self . init ( . ioError ( code : errno ) , path)
103109 }
104110 }
105111}
@@ -343,7 +349,7 @@ private class LocalFileSystem: FileSystem {
343349 }
344350
345351 guard FileManager . default. changeCurrentDirectoryPath ( path. pathString) else {
346- throw FileSystemError ( . unknownOSError , path)
352+ throw FileSystemError ( . couldNotChangeDirectory , path)
347353 }
348354 }
349355
@@ -440,7 +446,7 @@ private class LocalFileSystem: FileSystem {
440446 throw FileSystemError ( . ioError( code: errno) , path)
441447 }
442448 if n != contents. count {
443- throw FileSystemError ( . unknownOSError , path)
449+ throw FileSystemError ( . mismatchedByteCount ( expected : contents . count , actual : n ) , path)
444450 }
445451 break
446452 }
0 commit comments