Beispiel #1
0
        public unsafe bool Exists(string path)
        {
            void *dict = null;
            int   num  = MobileDevice.AFCFileInfoOpen(this.hAFC, path, ref dict);

            if (num == 0)
            {
                MobileDevice.AFCKeyValueClose(dict);
            }
            return(num == 0);
        }
Beispiel #2
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);
        }
Beispiel #3
0
        unsafe public void RefreshFileSystemInfo()
        {
            void * dict = null;
            void * key;
            void * val;
            string skey;
            string sval;
            long   lval;
            int    ival;
            int    ret = MobileDevice.AFCDeviceInfoOpen(hAFC, ref dict);

            if (ret == 0)
            {
                try
                {
                    while ((MobileDevice.AFCKeyValueRead(dict, out key, out val) == 0) && (skey = Marshal.PtrToStringAnsi(new IntPtr(key))) != null && (sval = Marshal.PtrToStringAnsi(new IntPtr(val))) != null)
                    {
                        switch (skey)
                        {
                        case "FSFreeBytes":
                            long.TryParse(sval, out lval);
                            fileSystemFreeBytes = lval;
                            break;

                        case "FSTotalBytes":
                            long.TryParse(sval, out lval);
                            fileSystemTotalBytes = lval;
                            break;

                        case "FSBlockSize":
                            Int32.TryParse(sval, out ival);
                            fileSystemBlockSize = ival;
                            break;

                        default:
                            System.Diagnostics.Trace.WriteLine(skey + ":" + sval);
                            break;
                        }
                    }
                }
                catch (AccessViolationException ave) { }
                finally
                {
                    MobileDevice.AFCKeyValueClose(dict);
                }
            }
        }
Beispiel #4
0
        public unsafe Dictionary <string, string> GetFileInfo(string path)
        {
            Dictionary <string, string> dictionary = new Dictionary <string, string>();
            void *dict = null;

            if ((MobileDevice.AFCFileInfoOpen(this.hAFC, path, ref dict) == 0) && (dict != null))
            {
                void *voidPtr2;
                void *voidPtr3;
                while (((MobileDevice.AFCKeyValueRead(dict, out voidPtr2, out voidPtr3) == 0) && (voidPtr2 != null)) && (voidPtr3 != null))
                {
                    string key  = Marshal.PtrToStringAnsi(new IntPtr(voidPtr2));
                    string str2 = Marshal.PtrToStringAnsi(new IntPtr(voidPtr3));
                    dictionary.Add(key, str2);
                }
                MobileDevice.AFCKeyValueClose(dict);
            }
            return(dictionary);
        }
Beispiel #5
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);
        }