@@ -115,7 +115,7 @@ public enum FileMode {
115115// FIXME: Design an asynchronous story?
116116public protocol FileSystem : class {
117117 /// Check whether the given path exists and is accessible.
118- func exists( _ path: AbsolutePath ) -> Bool
118+ func exists( _ path: AbsolutePath , followSymlink : Bool ) -> Bool
119119
120120 /// Check whether the given path is accessible and a directory.
121121 func isDirectory( _ path: AbsolutePath ) -> Bool
@@ -168,6 +168,11 @@ public protocol FileSystem: class {
168168/// Convenience implementations (default arguments aren't permitted in protocol
169169/// methods).
170170public extension FileSystem {
171+ /// exists override with default value.
172+ func exists( _ path: AbsolutePath ) -> Bool {
173+ return exists ( path, followSymlink: true )
174+ }
175+
171176 /// Default implementation of createDirectory(_:)
172177 func createDirectory( _ path: AbsolutePath ) throws {
173178 try createDirectory ( path, recursive: false )
@@ -197,8 +202,8 @@ private class LocalFileSystem: FileSystem {
197202 return filestat. st_mode & libc. S_IXUSR != 0
198203 }
199204
200- func exists( _ path: AbsolutePath ) -> Bool {
201- return Basic . exists ( path)
205+ func exists( _ path: AbsolutePath , followSymlink : Bool ) -> Bool {
206+ return Basic . exists ( path, followSymlink : followSymlink )
202207 }
203208
204209 func isDirectory( _ path: AbsolutePath ) -> Bool {
@@ -332,7 +337,7 @@ private class LocalFileSystem: FileSystem {
332337 }
333338
334339 func removeFileTree( _ path: AbsolutePath ) throws {
335- if self . exists ( path) {
340+ if self . exists ( path, followSymlink : false ) {
336341 try Basic . removeFileTree ( path)
337342 }
338343 }
@@ -509,7 +514,7 @@ public class InMemoryFileSystem: FileSystem {
509514
510515 // MARK: FileSystem Implementation
511516
512- public func exists( _ path: AbsolutePath ) -> Bool {
517+ public func exists( _ path: AbsolutePath , followSymlink : Bool ) -> Bool {
513518 do {
514519 return try getNode ( path) != nil
515520 } catch {
@@ -706,8 +711,8 @@ public class RerootedFileSystemView: FileSystem {
706711
707712 // MARK: FileSystem Implementation
708713
709- public func exists( _ path: AbsolutePath ) -> Bool {
710- return underlyingFileSystem. exists ( formUnderlyingPath ( path) )
714+ public func exists( _ path: AbsolutePath , followSymlink : Bool ) -> Bool {
715+ return underlyingFileSystem. exists ( formUnderlyingPath ( path) , followSymlink : followSymlink )
711716 }
712717
713718 public func isDirectory( _ path: AbsolutePath ) -> Bool {
0 commit comments