resourceValuesForKeys NSURLの判定
AppleScript サンプルコード
行番号 | ソース |
---|---|
001 | #!/usr/bin/env osascript |
002 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
003 | # |
004 | # |
005 | # com.cocolog-nifty.quicktimer.icefloe |
006 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
007 | use AppleScript version "2.6" |
008 | use framework "Foundation" |
009 | use framework "AppKit" |
010 | use framework "UniformTypeIdentifiers" |
011 | use scripting additions |
012 | |
013 | property refMe : a reference to current application |
014 | |
015 | set strFilePath to "/" as text |
016 | set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath) |
017 | set ocidFilePath to ocidFilePathStr's stringByStandardizingPath() |
018 | set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false) |
019 | |
020 | log doURLis(ocidFilePathURL, (refMe's NSURLIsVolumeKey)) |
021 | |
022 | |
023 | ########################## |
024 | # リソースキーチェック |
025 | ########################## |
026 | to doURLis(argFilePathURL, argNSURLResourceKey) |
027 | #キーを格納するArray |
028 | set ocidKeyArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0) |
029 | ocidKeyArray's addObject:(refMe's NSURLIsApplicationKey) |
030 | ocidKeyArray's addObject:(refMe's NSURLIsDirectoryKey) |
031 | ocidKeyArray's addObject:(refMe's NSURLIsAliasFileKey) |
032 | ocidKeyArray's addObject:(refMe's NSURLIsRegularFileKey) |
033 | ocidKeyArray's addObject:(refMe's NSURLIsPackageKey) |
034 | ocidKeyArray's addObject:(refMe's NSURLIsVolumeKey) |
035 | ocidKeyArray's addObject:(refMe's NSURLIsUbiquitousItemKey) |
036 | ocidKeyArray's addObject:(refMe's NSURLIsSymbolicLinkKey) |
037 | ocidKeyArray's addObject:(refMe's NSURLIsWritableKey) |
038 | ocidKeyArray's addObject:(refMe's NSURLIsReadableKey) |
039 | ocidKeyArray's addObject:(refMe's NSURLIsExecutableKey) |
040 | ocidKeyArray's addObject:(refMe's NSURLIsUserImmutableKey) |
041 | ocidKeyArray's addObject:(refMe's NSURLIsSystemImmutableKey) |
042 | ocidKeyArray's addObject:(refMe's NSURLIsHiddenKey) |
043 | ocidKeyArray's addObject:(refMe's NSURLIsExcludedFromBackupKey) |
044 | ocidKeyArray's addObject:(refMe's NSURLIsPurgeableKey) |
045 | ocidKeyArray's addObject:(refMe's NSURLIsSparseKey) |
046 | ocidKeyArray's addObject:(refMe's NSURLIsMountTriggerKey) |
047 | #リソース取得 |
048 | set listResponse to (argFilePathURL's resourceValuesForKeys:(ocidKeyArray) |error| :(reference)) |
049 | set ocidResourceValueDict to (item 1 of listResponse) |
050 | #判定 |
051 | set boolVolume to ocidResourceValueDict's valueForKey:(argNSURLResourceKey) |
052 | #判定値を戻す |
053 | if boolVolume = (missing value) then |
054 | error number -128 |
055 | else |
056 | return boolVolume as boolean |
057 | end if |
058 | |
059 | end doURLis |
AppleScriptで生成しました |
| 固定リンク