Check if file is executable

 Problem

I want to check if file, at a specific location, is executable.



 Recipe


// Create a FileManager instance

let fileManager = NSFileManager.defaultManager()

// Check if file exists, given its path

if fileManager.isExecutableFileAtPath("hello.swift") {
    print("File is executable")
} else {
    print("File is not executable")
}
				

Heard the news?

The Swift Cookbook for Swift 3 is at last here! For iBooks, Kindle and Paperback.
Hurry up - and Check it out! ;-)

 

 Playground