Determine a directory is a package in swift -
how can tell if file package rather directory?
var isdir = objcbool(false) let exists = nsfilemanager.defaultmanager().fileexistsatpath(path, isdirectory: &isdir) return isdir.boolvalue
this code returns true both directories , packages.
there’s cocoa method, isfilepackageatpath
, on nsworkspace that.
import cocoa let sw = nsworkspace.sharedworkspace() if sw.isfilepackageatpath("/applications/xcode.app") { // true, execute. } if sw.isfilepackageatpath("/usr/bin") { // false, won't execute. }
Comments
Post a Comment