Пример #1
0
        /// <summary>
        /// Determines whether the given path refers to an existing file or directory on the phone.
        /// </summary>
        /// <param name="path">The path to test.</param>
        /// <returns><c>true</c> if path refers to an existing file or directory, otherwise <c>false</c>.</returns>
        unsafe public bool Exists(string path)
        {
            void *data = null;

            int ret = MobileDevice.AFCFileInfoOpen(hAFC, path, ref data);

            if (ret == 0)
            {
                MobileDevice.AFCKeyValueClose(data);
            }

            return(ret == 0);
        }
Пример #2
0
        /// <summary>
        /// Returns the FileInfo dictionary
        /// </summary>
        /// <param name="path">The file or directory for which to retrieve information.</param>
        unsafe public Dictionary <string, string> GetFileInfo(string path)
        {
            Dictionary <string, string> ans = new Dictionary <string, string>();
            void *data = null;

            int ret = MobileDevice.AFCFileInfoOpen(hAFC, path, ref data);

            if (ret == 0 && data != null)
            {
                void *pname, pvalue;

                while (MobileDevice.AFCKeyValueRead(data, out pname, out pvalue) == 0 && pname != null && pvalue != null)
                {
                    string name  = Marshal.PtrToStringAnsi(new IntPtr(pname));
                    string value = Marshal.PtrToStringAnsi(new IntPtr(pvalue));
                    ans.Add(name, value);
                }

                MobileDevice.AFCKeyValueClose(data);
            }

            return(ans);
        }