示例#1
0
        public static List <string> GetFileListFromEventRef(IntPtr eventRef)
        {
            AEDesc list  = GetEventParameter <AEDesc> (eventRef, CarbonEventParameterName.DirectObject, CarbonEventParameterType.AEList);
            long   count = AECountItems(ref list);
            var    files = new List <string> ();

            for (int i = 1; i <= count; i++)
            {
                FSRef  fsRef = AEGetNthPtr <FSRef> (ref list, i, CarbonEventParameterType.FSRef);
                string file  = FSRefToPath(ref fsRef);
                if (!string.IsNullOrEmpty(file))
                {
                    files.Add(file);
                }
            }
            CheckReturn(AEDisposeDesc(ref list));
            return(files);
        }
示例#2
0
        public static string FSRefToPath(ref FSRef fsRef)
        {
            //FIXME: is this big enough?
            const int MAX_LENGTH = 4096;
            IntPtr    buf        = IntPtr.Zero;
            string    ret;

            try {
                buf = Marshal.AllocHGlobal(MAX_LENGTH);
                CheckReturn(FSRefMakePath(ref fsRef, buf, (uint)MAX_LENGTH));
                //FIXME: on Mono, auto is UTF-8, which is correct but I'd prefer to be more explicit
                ret = Marshal.PtrToStringAuto(buf, MAX_LENGTH);
            } finally {
                if (buf != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(buf);
                }
            }
            return(ret);
        }
示例#3
0
 static extern int FSRefMakePath(ref FSRef fsRef, IntPtr buffer, uint bufferSize);