AppleScript名:指定EnumがどのFrameworkに所属しているか検索 v2 |
— Created 2017-10-13 by Takaaki Naganoya — 2017 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" use framework "AppKit" property NSFileManager : a reference to current application’s NSFileManager property NSString : a reference to current application’s NSString property NSPredicate : a reference to current application’s NSPredicate property NSMutableArray : a reference to current application’s NSMutableArray property NSUTF8StringEncoding : a reference to current application’s NSUTF8StringEncoding set a1Res to searchEnumFromHeaderFiles("NSUTF8StringEncoding") of me –> {"DiscRecording.framework", "Foundation.framework", "SpriteKit.framework"} set a2Res to searchEnumFromHeaderFiles("NSNumberFormatterRoundUp") of me –> {"Foundation.framework"} set a3Res to searchEnumFromHeaderFiles("NSParagraphStyleAttributeName") of me –> {"AppKit.framework"} on searchEnumFromHeaderFiles(targString) set aClass to current application’s NSClassFromString(targString) if aClass is not equal to missing value then return false set dPath to POSIX path of (path to application id "com.apple.dt.Xcode") set aFol to dPath & "Contents/Developer/Platforms/MacOSX.platform/" & "Developer/SDKs/MacOSX.sdk/System/Library/Frameworks" set bList to retFullPathWithinAFolderWithRecursiveFilterByExt(aFol, "h") of me set matchedList to {} repeat with i in bList set j to contents of i set aStr to (NSString’s stringWithContentsOfFile:j encoding:NSUTF8StringEncoding |error|:(missing value)) if aStr ≠ missing value then set aRange to (aStr’s rangeOfString:targString) if aRange’s location() ≠ current application’s NSNotFound and (aRange’s location()) < 9.99999999E+8 then set tmpStr to (current application’s NSString’s stringWithString:j) set pathList to tmpStr’s pathComponents() set thePred to (current application’s NSPredicate’s predicateWithFormat:"pathExtension == ’framework’") set aRes to (pathList’s filteredArrayUsingPredicate:thePred)’s firstObject() as text set the end of matchedList to aRes end if end if end repeat set aArray to current application’s NSArray’s arrayWithArray:matchedList set bArray to aArray’s valueForKeyPath:"@distinctUnionOfObjects.self" return bArray as list end searchEnumFromHeaderFiles –指定フォルダ以下のすべてのファイルを再帰で取得(拡張子で絞り込み) on retFullPathWithinAFolderWithRecursiveFilterByExt(aFol, aExt) set anArray to NSMutableArray’s array() set aPath to NSString’s stringWithString:aFol set dirEnum to NSFileManager’s defaultManager()’s enumeratorAtPath:aPath repeat set aName to (dirEnum’s nextObject()) if aName = missing value then exit repeat set aFullPath to aPath’s stringByAppendingPathComponent:aName anArray’s addObject:aFullPath end repeat set thePred to NSPredicate’s predicateWithFormat:"pathExtension == [c]%@" argumentArray:{aExt} set bArray to anArray’s filteredArrayUsingPredicate:thePred return bArray as list end retFullPathWithinAFolderWithRecursiveFilterByExt |
(Visited 38 times, 1 visits today)