[swift-users] FileManager alway returns true in Linux
Proyb P
proyb6 at gmail.com
Fri Mar 10 14:32:50 CST 2017
MacOS shown different behavior.
On Saturday, 11 March 2017, John Smith <jsmith5pam at yahoo.com> wrote:
> That is correct as long as the directory “files/“ exists. filename is set
> to an empty string this your concat statement appends an empty string to
> your constant string of “files/“ resulting in the path “files/“.
>
>
> > On Mar 10, 2017, at 1:53 PM, Proyb P via swift-users <
> swift-users at swift.org <javascript:;>> wrote:
> >
> > let filename = ""
> > let checkfile = FileManager.default
> > var isDir : ObjCBool = false
> > if checkfile.fileExists(atPath: "files/"+filename, isDirectory: &isDir) {
> > print("true")
> > } else {
> > print("false")
> > }
> >
> > 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"
> > _______________________________________________
> > swift-users mailing list
> > swift-users at swift.org <javascript:;>
> > https://lists.swift.org/mailman/listinfo/swift-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170311/876d09be/attachment.html>
More information about the swift-users
mailing list