나는 방금 검색 한 것과 같은 소리 인 Alias Manager에 대해 알았습니다. 불행히도, 그것은 사용되지 않을 것 같습니다. (related question) Some info about the deprecation.
(Another related question) 이러한 기능을 제공하는 NSURL class도 있습니다.
파이썬 코드 :
import AppKit
def getFileNativeId(filepath):
if not os.path.isfile(filepath): return None
filepath = os.path.abspath(filepath)
filepath = unicode(filepath)
url = AppKit.NSURL.alloc().initFileURLWithPath_(filepath)
bookmark = url.bookmarkDataWithOptions_includingResourceValuesForKeys_relativeToURL_error_(AppKit.NSURLBookmarkCreationPreferFileIDResolution,None,None,None)
bytes = bookmark[0].bytes().tobytes()
return bytes
def getPathByNativeId(fileid):
nsdata = AppKit.NSData.alloc().initWithBytes_length_(fileid, len(fileid))
url, _, _ = AppKit.NSURL.URLByResolvingBookmarkData_options_relativeToURL_bookmarkDataIsStale_error_(nsdata, AppKit.NSURLBookmarkResolutionWithoutUI, None,None,None)
if not url: return None
return unicode(url.path())