コード例 #1
0
        /// <include file='.\BusyBox.xml' path='/BusyBox/ExecuteRootShellCommand/*'/>
        public void ExecuteRootShellCommand(String command, IShellOutputReceiver receiver, params object[] commandArgs)
        {
            command.ThrowIfNullOrWhiteSpace("command");
            var cmd = String.Format("{0} {1}", BUSYBOX_COMMAND, String.Format(command, commandArgs));

            Log.d("executing (su): {0}", cmd);
            Device.ExecuteRootShellCommand(cmd, receiver);
        }
コード例 #2
0
ファイル: FileSystem.cs プロジェクト: parkheeyoung/madb
        /// <summary>
        /// Creates the specified path.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <returns></returns>
        public FileEntry Create(String path)
        {
            Device.ThrowIfNull("Device");

            path.ThrowIfNullOrWhiteSpace("path");

            if (!Device.IsOffline)
            {
                if (Exists(path))
                {
                    throw new ArgumentException("The specified path already exists.");
                }
                else
                {
                    var cer     = new CommandErrorReceiver();
                    var escaped = LinuxPath.Escape(path);
                    // use native touch command if its available.
                    var cmd     = ">";
                    var command = String.Format("{0} {1}", cmd, escaped);
                    if (Device.CanSU())
                    {
                        Device.ExecuteRootShellCommand(command, cer);
                    }
                    else
                    {
                        Device.ExecuteShellCommand(command, cer);
                    }
                    if (!String.IsNullOrEmpty(cer.ErrorMessage))
                    {
                        throw new IOException(String.Format("Error creating file: {0}", cer.ErrorMessage));
                    }
                    else
                    {
                        // at this point, the newly created file should exist.
                        return(this.fileListingService.FindFileEntry(path));
                    }
                }
            }
            else
            {
                throw new IOException("Device is not online");
            }
        }