Beispiel #1
0
        public unsafe string[] GetFiles(string path)
        {
            if (!_connected)
            {
                throw new Exception("Not connected to phone");
            }
            void *dir = null;

            if (MobileDevice.AFCDirectoryOpen(hAFC, Encoding.UTF8.GetBytes(path), ref dir) != 0)
            {
                throw new Exception("Path does not exist");
            }
            string buffer = null;
            var    list   = new ArrayList();

            MobileDevice.AFCDirectoryRead(hAFC, dir, ref buffer);
            while (buffer != null)
            {
                if (!IsDirectory(string.Format("{0}/{1}", path, buffer)))
                {
                    list.Add(buffer);
                }
                MobileDevice.AFCDirectoryRead(hAFC, dir, ref buffer);
            }
            MobileDevice.AFCDirectoryClose(hAFC, dir);
            return((string[])list.ToArray(typeof(string)));
        }
Beispiel #2
0
        public unsafe void GetFileInfo(string path, out ulong size, out bool directory)
        {
            string str;
            var    fileInfo = GetFileInfo(path);

            size = fileInfo.ContainsKey("st_size") ? ulong.Parse(fileInfo["st_size"]) : 0L;
            bool flag = false;

            directory = false;
            if (fileInfo.ContainsKey("st_ifmt") && ((str = fileInfo["st_ifmt"]) != null))
            {
                if (!(str == "S_IFDIR"))
                {
                    if (str == "S_IFLNK")
                    {
                        flag = true;
                    }
                }
                else
                {
                    directory = true;
                }
            }
            if (flag)
            {
                void *dir = null;
                if (directory = MobileDevice.AFCDirectoryOpen(hAFC, Encoding.UTF8.GetBytes(path), ref dir) == 0)
                {
                    MobileDevice.AFCDirectoryClose(hAFC, dir);
                }
            }
        }
Beispiel #3
0
        public unsafe string[] GetFiles(string path)
        {
            if (!this.connected)
            {
                throw new Exception("Not connected to phone");
            }
            string s   = this.FullPath(this.current_directory, path);
            void * dir = null;

            if (MobileDevice.AFCDirectoryOpen(this.hAFC, Encoding.UTF8.GetBytes(s), ref dir) != 0)
            {
                throw new Exception("Path does not exist");
            }
            string    buffer = null;
            ArrayList list   = new ArrayList();

            MobileDevice.AFCDirectoryRead(this.hAFC, dir, ref buffer);
            while (buffer != null)
            {
                if (!this.IsDirectory(this.FullPath(s, buffer)))
                {
                    list.Add(buffer);
                }
                MobileDevice.AFCDirectoryRead(this.hAFC, dir, ref buffer);
            }
            MobileDevice.AFCDirectoryClose(this.hAFC, dir);
            return((string[])list.ToArray(typeof(string)));
        }
Beispiel #4
0
        public unsafe string[] GetDirectories(string path)
        {
            if (!this.IsConnected)
            {
                throw new Exception("Not connected to phone");
            }
            void * dir = null;
            string str = this.FullPath(this.CurrentDirectory, path);
            int    num = MobileDevice.AFCDirectoryOpen(this.hAFC, str, ref dir);

            if (num != 0)
            {
                throw new Exception("Path does not exist: " + num.ToString());
            }
            string    buffer = null;
            ArrayList list   = new ArrayList();

            MobileDevice.AFCDirectoryRead(this.hAFC, dir, ref buffer);
            while (buffer != null)
            {
                if (((buffer != ".") && (buffer != "..")) && this.IsDirectory(this.FullPath(str, buffer)))
                {
                    list.Add(buffer);
                }
                MobileDevice.AFCDirectoryRead(this.hAFC, dir, ref buffer);
            }
            MobileDevice.AFCDirectoryClose(this.hAFC, dir);
            return((string[])list.ToArray(typeof(string)));
        }
Beispiel #5
0
        public unsafe void GetFileInfo(string path, out ulong size, out bool directory)
        {
            Dictionary <string, string> fileInfo = this.GetFileInfo(path);

            size = fileInfo.ContainsKey("st_size") ? ulong.Parse(fileInfo["st_size"]) : ((ulong)0L);
            bool flag = false;

            directory = false;
            if (fileInfo.ContainsKey("st_ifmt"))
            {
                string str = fileInfo["st_ifmt"];
                if (str != null)
                {
                    if (!(str == "S_IFDIR"))
                    {
                        if (str == "S_IFLNK")
                        {
                            flag = true;
                        }
                    }
                    else
                    {
                        directory = true;
                    }
                }
            }
            if (flag)
            {
                bool  flag3;
                void *dir = null;
                directory = flag3 = MobileDevice.AFCDirectoryOpen(this.hAFC, path, ref dir) == 0;
                if (flag3)
                {
                    MobileDevice.AFCDirectoryClose(this.hAFC, dir);
                }
            }
        }