[swift-users] FileManager alway returns true in Linux

Proyb P proyb6 at gmail.com
Fri Mar 10 12:53:51 CST 2017

let filename = ""
let checkfile = FileManager.default
var isDir : ObjCBool = false
if checkfile.fileExists(atPath: "files/"+filename, isDirectory: &isDir) {
} else {

On Linux, if the "filename" variable is empty string, checkfile will
returns as true which should be return as false since the file is not
found. macOS is working fine.

A temporary workarounds is to use
let filename = "NOTFOUND"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170311/56dfd141/attachment.html>

More information about the swift-users mailing list