Esempio n. 1
0
        /// <summary>
        /// Chmods the specified path.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="permissions">The permissions.</param>
        public void Chmod(string path, FilePermissions permissions)
        {
            FileEntry            entry = Device.FileListingService.FindFileEntry(path);
            CommandErrorReceiver cer   = new CommandErrorReceiver();

            Device.ExecuteShellCommand("chmod {0} {1}", cer, permissions.ToChmod(), entry.FullEscapedPath);
        }
Esempio n. 2
0
        /// <summary>
        /// Makes the directory.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="forceDeviceMethod">if set to <c>true</c> forces the use of the "non-busybox" method.</param>
        public void MakeDirectory(String path, bool forceDeviceMethod)
        {
            Device.ThrowIfNull("Device");
            path.ThrowIfNullOrWhiteSpace("path");

            CommandErrorReceiver cer = new CommandErrorReceiver( );

            try {
                //var fileEntry = FileEntry.FindOrCreate ( Device, path );
                // if we have busybox we can use the mkdir in there as it supports --parents
                if (Device.BusyBox.Available && !forceDeviceMethod)
                {
                    try {
                        Device.BusyBox.ExecuteShellCommand("mkdir -p {0}", cer, path);
                    } catch {
                        try {
                            // if there was an error, then fallback too.
                            MakeDirectoryFallbackInternal(path, cer);
                        } catch { }
                    }
                }
                else
                {
                    // if busybox is not available then we have to fallback
                    MakeDirectoryFallbackInternal(path, cer);
                }
            } catch {
            }
            if (!String.IsNullOrEmpty(cer.ErrorMessage))
            {
                throw new IOException(cer.ErrorMessage);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// this is a fallback if the mkdir -p fails for somereason
        /// </summary>
        /// <param name="path"></param>
        internal void MakeDirectoryFallbackInternal(string path, CommandErrorReceiver cer)
        {
            string[]  segs    = path.Split(new char[] { LinuxPath.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries);
            FileEntry current = Device.FileListingService.Root;

            foreach (var pathItem in segs)
            {
                FileEntry[] entries = Device.FileListingService.GetChildren(current, true, null);
                bool        found   = false;
                foreach (var e in entries)
                {
                    if (string.Compare(e.Name, pathItem, false) == 0)
                    {
                        current = e;
                        found   = true;
                        break;
                    }
                }

                if (!found)
                {
                    current = FileEntry.FindOrCreate(Device, LinuxPath.Combine(current.FullPath, pathItem + new string(new char[] { LinuxPath.DirectorySeparatorChar })));
                    Device.ExecuteShellCommand("mkdir {0}", cer, current.FullEscapedPath);
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Unmounts the specified mount point.
        /// </summary>
        /// <param name="mountPoint">The mount point.</param>
        /// <param name="options">The options.</param>
        public void Unmount(String mountPoint, String options)
        {
            mountPoint.ThrowIfNull("mountPoint");
            Device.ThrowIfNull("Device");

            CommandErrorReceiver cer = new CommandErrorReceiver();

            Device.ExecuteShellCommand("umount {1} {0}", cer, !String.IsNullOrEmpty(options) ? String.Format("-o {0}", options) : String.Empty, mountPoint);
        }
Esempio n. 5
0
        /// <summary>
        /// Attempts to mount the mount point to the associated device without knowing the device or the type.
        /// Some devices may not support this method.
        /// </summary>
        /// <param name="mountPoint"></param>
        public void Mount(String mountPoint)
        {
            mountPoint.ThrowIfNull("mountPoint");
            Device.ThrowIfNull("Device");

            CommandErrorReceiver cer = new CommandErrorReceiver();

            Device.ExecuteShellCommand("mount {0}", cer, mountPoint);
        }
Esempio n. 6
0
        /// <summary>
        /// Chmods the specified path.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="permissions">The permissions.</param>
        public void Chmod( String path, String permissions )
        {
            Device.ThrowIfNull ( "Device" );
            path.ThrowIfNullOrWhiteSpace ( "path" );
            permissions.ThrowIfNullOrWhiteSpace ( "permissions" );

            FileEntry entry = Device.FileListingService.FindFileEntry ( path );
            CommandErrorReceiver cer = new CommandErrorReceiver ( );
            Device.ExecuteShellCommand ( "chmod {0} {1}", cer, permissions, entry.FullEscapedPath );
        }
        /// <summary>
        /// Chmods the specified path.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="permissions">The permissions.</param>
        public void Chmod(String path, String permissions)
        {
            Device.ThrowIfNull("Device");
            path.ThrowIfNullOrWhiteSpace("path");
            permissions.ThrowIfNullOrWhiteSpace("permissions");

            CommandErrorReceiver cer = new CommandErrorReceiver( );

            Device.ExecuteShellCommand("chmod {0} {1}", cer, permissions, path);
        }
Esempio n. 8
0
        /// <summary>
        /// Deletes the specified path.
        /// </summary>
        /// <param name="path">The path.</param>
        public void Delete(String path)
        {
            Device.ThrowIfNull("Device");
            path.ThrowIfNullOrWhiteSpace("path");

            CommandErrorReceiver cer   = new CommandErrorReceiver( );
            FileEntry            entry = Device.FileListingService.FindFileEntry(path);

            Delete(entry);
        }
Esempio n. 9
0
        /// <summary>
        /// Moves the specified source to the specified destination.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="destination">The destination.</param>
        public void Move(string source, string destination)
        {
            CommandErrorReceiver cer = new CommandErrorReceiver();
            FileEntry            sfe = Device.FileListingService.FindFileEntry(source);

            Device.ExecuteShellCommand("mv {0} {1}", cer, sfe.FullEscapedPath, destination);
            if (!string.IsNullOrEmpty(cer.ErrorMessage))
            {
                throw new IOException(cer.ErrorMessage);
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Mounts the specified device.
        /// </summary>
        /// <param name="mountPoint">The mp.</param>
        /// <param name="options">The options.</param>
        public void Mount(MountPoint mountPoint, String options)
        {
            mountPoint.ThrowIfNull("mountPoint");
            Device.ThrowIfNull("Device");

            CommandErrorReceiver cer = new CommandErrorReceiver();

            Device.ExecuteShellCommand("mount {0} {4} -t {1} {2} {3}", cer, mountPoint.IsReadOnly ? "-r" : "-w",
                                       mountPoint.FileSystem, mountPoint.Block, mountPoint.Name,
                                       !String.IsNullOrEmpty(options) ? String.Format("-o {0}", options) : String.Empty);
        }
Esempio n. 11
0
        /// <summary>
        /// Chmods the specified path.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="permissions">The permissions.</param>
        public void Chmod(String path, FilePermissions permissions)
        {
            Device.ThrowIfNull("Device");
            path.ThrowIfNullOrWhiteSpace("path");
            permissions.ThrowIfNull("permissions");

            FileEntry            entry = Device.FileListingService.FindFileEntry(path);
            CommandErrorReceiver cer   = new CommandErrorReceiver( );

            Device.ExecuteShellCommand("chmod {0} {1}", cer, permissions.ToChmod( ), entry.FullEscapedPath);
        }
Esempio n. 12
0
        /// <summary>
        /// Mounts the specified device.
        /// </summary>
        /// <param name="mp">The mp.</param>
        /// <param name="options">The options.</param>
        public void Mount(MountPoint mp, string options)
        {
            CommandErrorReceiver cer = new CommandErrorReceiver();

            if (Device.BusyBox.Available)
            {
                Device.ExecuteShellCommand("busybox mount {0} {4} -t {1} {2} {3}", cer, mp.IsReadOnly ? "-r" : "-w", mp.FileSystem, mp.Block, mp.Name, !string.IsNullOrEmpty(options) ? string.Format("-o {0}", options) : string.Empty);
            }
            else
            {
                Device.ExecuteShellCommand("mount {0} {4} -t {1} {2} {3}", cer, mp.IsReadOnly ? "-r" : "-w", mp.FileSystem, mp.Block, mp.Name, !string.IsNullOrEmpty(options) ? string.Format("-o {0}", options) : string.Empty);
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Attempts to mount the mount point to the associated device without knowing the device or the type.
        /// Some devices may not support this method.
        /// </summary>
        /// <param name="mountPoint"></param>
        public void Mount(string mountPoint)
        {
            CommandErrorReceiver cer = new CommandErrorReceiver();

            if (Device.BusyBox.Available)
            {
                Device.ExecuteShellCommand("busybox mount {0}", cer, mountPoint);
            }
            else
            {
                Device.ExecuteShellCommand("mount {0}", cer, mountPoint);
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Unmounts the specified mount point.
        /// </summary>
        /// <param name="mountPoint">The mount point.</param>
        /// <param name="options">The options.</param>
        public void Unmount(string mountPoint, string options)
        {
            CommandErrorReceiver cer = new CommandErrorReceiver();

            if (Device.BusyBox.Available)
            {
                Device.ExecuteShellCommand("busybox umount {1} {0}", cer, !string.IsNullOrEmpty(options) ? string.Format("-o {0}", options) : string.Empty, mountPoint);
            }
            else
            {
                Device.ExecuteShellCommand("umount {1} {0}", cer, !string.IsNullOrEmpty(options) ? string.Format("-o {0}", options) : string.Empty, mountPoint);
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Deletes the specified path.
        /// </summary>
        /// <param name="fileEntry">The file entry.</param>
        /// <exception cref="System.IO.IOException">If the command fails.</exception>
        /// <exception cref="System.ArgumentNullException">If device is null or if path is null or empty.</exception>

        public void Delete(FileEntry fileEntry)
        {
            Device.ThrowIfNull("Device");
            fileEntry.ThrowIfNull("fileEntry");
            if (fileEntry.Exists)
            {
                CommandErrorReceiver cer = new CommandErrorReceiver( );
                Device.ExecuteShellCommand("rm -f {0} {1}", cer, fileEntry.IsDirectory ? "-r" : String.Empty, fileEntry.FullResolvedPath);

                if (!String.IsNullOrEmpty(cer.ErrorMessage))
                {
                    throw new IOException(cer.ErrorMessage);
                }
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Deletes the specified path.
        /// </summary>
        /// <param name="path">The path.</param>
        public void Delete(string path)
        {
            CommandErrorReceiver cer   = new CommandErrorReceiver();
            FileEntry            entry = Device.FileListingService.FindFileEntry(path);

            if (entry != null)
            {
                Device.ExecuteShellCommand("rm -f {0} {1}", cer, entry.IsDirectory ? "-r" : string.Empty, entry.FullEscapedPath);
            }

            if (!string.IsNullOrEmpty(cer.ErrorMessage))
            {
                throw new IOException(cer.ErrorMessage);
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Moves the specified source to the specified destination.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="destination">The destination.</param>
        public void Move(String source, String destination)
        {
            Device.ThrowIfNull("Device");
            source.ThrowIfNullOrWhiteSpace("source");
            destination.ThrowIfNullOrWhiteSpace("destination");

            CommandErrorReceiver cer = new CommandErrorReceiver( );
            FileEntry            sfe = Device.FileListingService.FindFileEntry(source);

            Device.ExecuteShellCommand("mv {0} {1}", cer, sfe.FullEscapedPath, destination);
            if (!String.IsNullOrEmpty(cer.ErrorMessage))
            {
                throw new IOException(cer.ErrorMessage);
            }
        }
Esempio n. 18
0
        /// <summary>
        /// Creates the specified path.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <returns></returns>
        public FileEntry Create(string path)
        {
            if (Device == null)
            {
                throw new ArgumentNullException("device", "Device cannot be null.");
            }
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException("path", "Path cannot be null or empty.");
            }

            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     = Device.BusyBox.Available ? "touch" : ">";
                    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(Device.FileListingService.FindFileEntry(path));
                    }
                }
            }
            else
            {
                throw new IOException("Device is not online");
            }
        }
Esempio n. 19
0
        /// <summary>
        /// Attempts to mount the mount point to the associated device without knowing the device or the type.
        /// Some devices may not support this method.
        /// </summary>
        /// <param name="mountPoint"></param>
        public void Mount(String mountPoint)
        {
            mountPoint.ThrowIfNull("mountPoint");
            Device.ThrowIfNull("Device");

            CommandErrorReceiver cer = new CommandErrorReceiver( );

            if (Device.BusyBox.Available)
            {
                Device.ExecuteShellCommand("busybox mount {0}", cer, mountPoint);
            }
            else
            {
                Device.ExecuteShellCommand("mount {0}", cer, mountPoint);
            }
        }
Esempio n. 20
0
        /// <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");
            }
        }
Esempio n. 21
0
        /// <summary>
        /// Deletes the specified path.
        /// </summary>
        /// <param name="fileEntry">The file entry.</param>
        /// <exception cref="System.IO.IOException">If the command fails.</exception>
        public void Delete(FileEntry fileEntry)
        {
            /// <exception cref="System.ArgumentNullException">
            /// If device is null
            /// or
            /// If path is null or empty.
            /// </exception>
            Device.ThrowIfNull("Device");
            fileEntry.ThrowIfNull("fileEntry");
            if (fileEntry.Exists)
            {
                CommandErrorReceiver cer = new CommandErrorReceiver( );
                Device.ExecuteShellCommand("rm -f {0} {1}", cer, fileEntry.IsDirectory ? "-r" : String.Empty, fileEntry.FullResolvedPath);

                if (!String.IsNullOrEmpty(cer.ErrorMessage))
                {
                    throw new IOException(cer.ErrorMessage);
                }
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Makes the directory.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="forceDeviceMethod">if set to <see langword="true"/> forces the use of the "non-busybox" method.</param>
        public void MakeDirectory(String path, bool forceDeviceMethod)
        {
            Device.ThrowIfNull("Device");
            path.ThrowIfNullOrWhiteSpace("path");

            CommandErrorReceiver cer = new CommandErrorReceiver();

            try
            {
                // if busybox is not available then we have to fallback
                MakeDirectoryFallbackInternal(path, cer);
            }
            catch
            {
            }
            if (!String.IsNullOrEmpty(cer.ErrorMessage))
            {
                throw new IOException(cer.ErrorMessage);
            }
        }
Esempio n. 23
0
        /// <summary>
        /// Makes the directory.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="forceDeviceMethod">if set to <c>true</c> forces the use of the "non-busybox" method.</param>
        public void MakeDirectory( String path, bool forceDeviceMethod )
        {
            Device.ThrowIfNull ( "Device" );
            path.ThrowIfNullOrWhiteSpace ( "path" );

            CommandErrorReceiver cer = new CommandErrorReceiver ( );
            try {
                //var fileEntry = FileEntry.FindOrCreate ( Device, path );
                // if we have busybox we can use the mkdir in there as it supports --parents
                if ( Device.BusyBox.Available && !forceDeviceMethod ) {
                    try {
                        Device.BusyBox.ExecuteShellCommand ( "mkdir -p {0}", cer, path );
                    } catch {
                        try {
                            // if there was an error, then fallback too.
                            MakeDirectoryFallbackInternal ( path, cer );
                        } catch { }
                    }
                } else {
                    // if busybox is not available then we have to fallback
                    MakeDirectoryFallbackInternal ( path, cer );
                }
            } catch {

            }
            if ( !String.IsNullOrEmpty ( cer.ErrorMessage ) ) {
                throw new IOException ( cer.ErrorMessage );
            }
        }
Esempio n. 24
0
        /// <summary>
        /// Deletes the specified path.
        /// </summary>
        /// <param name="path">The path.</param>
        public void Delete( String path )
        {
            Device.ThrowIfNull ( "Device" );
            path.ThrowIfNullOrWhiteSpace ( "path" );

            CommandErrorReceiver cer = new CommandErrorReceiver ( );
            FileEntry entry = Device.FileListingService.FindFileEntry ( path );

            Delete ( entry );
        }
Esempio n. 25
0
        /// <summary>
        /// Deletes the specified path.
        /// </summary>
        /// <param name="path">The path.</param>
        public void Delete( FileEntry fileEntry )
        {
            Device.ThrowIfNull ( "Device" );
            fileEntry.ThrowIfNull ( "fileEntry" );
            if ( fileEntry.Exists ) {
                CommandErrorReceiver cer = new CommandErrorReceiver ( );
                Device.ExecuteShellCommand ( "rm -f {0} {1}", cer, fileEntry.IsDirectory ? "-r" : String.Empty, fileEntry.FullResolvedPath );

                if ( !String.IsNullOrEmpty ( cer.ErrorMessage ) ) {
                    throw new IOException ( cer.ErrorMessage );
                }
            }
        }
Esempio n. 26
0
 /// <summary>
 /// this is a fallback if the mkdir -p fails for somereason
 /// </summary>
 /// <param name="path"></param>
 /// <param name="cer"></param>
 internal void MakeDirectoryFallbackInternal(String path, CommandErrorReceiver cer)
 {
     Device.ExecuteShellCommand("mkdir {0}", cer, path);
 }
Esempio n. 27
0
        /// <summary>
        /// Makes the directory.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="forceDeviceMethod">if set to <see langword="true"/> forces the use of the "non-busybox" method.</param>
        public void MakeDirectory(String path, bool forceDeviceMethod)
        {
            Device.ThrowIfNull("Device");
            path.ThrowIfNullOrWhiteSpace("path");

            CommandErrorReceiver cer = new CommandErrorReceiver();
            try
            {
                // if busybox is not available then we have to fallback
                MakeDirectoryFallbackInternal(path, cer);
            }
            catch
            {

            }
            if (!String.IsNullOrEmpty(cer.ErrorMessage))
            {
                throw new IOException(cer.ErrorMessage);
            }
        }
Esempio n. 28
0
        /// <summary>
        /// Attempts to mount the mount point to the associated device without knowing the device or the type.
        /// Some devices may not support this method.
        /// </summary>
        /// <param name="mountPoint"></param>
        public void Mount(String mountPoint)
        {
            mountPoint.ThrowIfNull("mountPoint");
            Device.ThrowIfNull("Device");

            CommandErrorReceiver cer = new CommandErrorReceiver();
            Device.ExecuteShellCommand("mount {0}", cer, mountPoint);
        }
Esempio n. 29
0
        /// <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 = Device.BusyBox.Available ? "touch" : ">";
                    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 Device.FileListingService.FindFileEntry ( path );
                    }
                }
            } else {
                throw new IOException ( "Device is not online" );
            }
        }
Esempio n. 30
0
        /// <summary>
        /// Deletes the specified path.
        /// </summary>
        /// <param name="fileEntry">The file entry.</param>
        /// <exception cref="System.IO.IOException">If the command fails.</exception>
        public void Delete( FileEntry fileEntry )
        {
            /// <exception cref="System.ArgumentNullException">
            /// If device is null
            /// or
            /// If path is null or empty.
            /// </exception>
            Device.ThrowIfNull("Device");
            fileEntry.ThrowIfNull ( "fileEntry" );
            if ( fileEntry.Exists ) {
                CommandErrorReceiver cer = new CommandErrorReceiver ( );
                Device.ExecuteShellCommand ( "rm -f {0} {1}", cer, fileEntry.IsDirectory ? "-r" : String.Empty, fileEntry.FullResolvedPath );

                if ( !String.IsNullOrEmpty ( cer.ErrorMessage ) ) {
                    throw new IOException ( cer.ErrorMessage );
                }
            }
        }
Esempio n. 31
0
        /// <summary>
        /// Copies the specified source to the specified destination.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="destination">The destination.</param>
        public void Copy( String source, String destination )
        {
            Device.ThrowIfNull ( "Device" );
            source.ThrowIfNullOrWhiteSpace ( "source" );
            destination.ThrowIfNullOrWhiteSpace ( "destination" );

            CommandErrorReceiver cer = new CommandErrorReceiver ( );
            FileEntry sfe = Device.FileListingService.FindFileEntry ( source );

            Device.ExecuteShellCommand ( "cat {0} > {1}", cer, sfe.FullEscapedPath, destination );
            if ( !String.IsNullOrEmpty ( cer.ErrorMessage ) ) {
                throw new IOException ( cer.ErrorMessage );
            }
        }
Esempio n. 32
0
        /// <summary>
        /// Mounts the specified device.
        /// </summary>
        /// <param name="mountPoint">The mp.</param>
        /// <param name="options">The options.</param>
        public void Mount( MountPoint mountPoint, String options )
        {
            mountPoint.ThrowIfNull ( "mountPoint" );
            Device.ThrowIfNull ( "Device" );

            CommandErrorReceiver cer = new CommandErrorReceiver ( );
            if ( Device.BusyBox.Available ) {
                Device.ExecuteShellCommand ( "busybox mount {0} {4} -t {1} {2} {3}", cer, mountPoint.IsReadOnly ? "-r" : "-w",
                    mountPoint.FileSystem, mountPoint.Block, mountPoint.Name,
                    !String.IsNullOrEmpty ( options ) ? String.Format ( "-o {0}", options ) : String.Empty );
            } else {
                Device.ExecuteShellCommand ( "mount {0} {4} -t {1} {2} {3}", cer, mountPoint.IsReadOnly ? "-r" : "-w",
                    mountPoint.FileSystem, mountPoint.Block, mountPoint.Name,
                    !String.IsNullOrEmpty ( options ) ? String.Format ( "-o {0}", options ) : String.Empty );
            }
        }
Esempio n. 33
0
 /// <summary>
 /// this is a fallback if the mkdir -p fails for somereason
 /// </summary>
 /// <param name="path"></param>
 /// <param name="cer"></param>
 internal void MakeDirectoryFallbackInternal( String path, CommandErrorReceiver cer )
 {
     Device.ExecuteShellCommand ( "mkdir {0}", cer, path );
 }
Esempio n. 34
0
        /// <summary>
        /// Unmounts the specified mount point.
        /// </summary>
        /// <param name="mountPoint">The mount point.</param>
        /// <param name="options">The options.</param>
        public void Unmount( String mountPoint, String options )
        {
            mountPoint.ThrowIfNull ( "mountPoint" );
            Device.ThrowIfNull ( "Device" );

            CommandErrorReceiver cer = new CommandErrorReceiver ( );
            if ( Device.BusyBox.Available ) {
                Device.ExecuteShellCommand ( "busybox umount {1} {0}", cer, !String.IsNullOrEmpty ( options ) ? String.Format ( "-o {0}", options ) : String.Empty, mountPoint );
            } else {
                Device.ExecuteShellCommand ( "umount {1} {0}", cer, !String.IsNullOrEmpty ( options ) ? String.Format ( "-o {0}", options ) : String.Empty, mountPoint );
            }
        }
Esempio n. 35
0
        /// <summary>
        /// Attempts to mount the mount point to the associated device without knowing the device or the type.
        /// Some devices may not support this method.
        /// </summary>
        /// <param name="mountPoint"></param>
        public void Mount( String mountPoint )
        {
            mountPoint.ThrowIfNull ( "mountPoint" );
            Device.ThrowIfNull ( "Device" );

            CommandErrorReceiver cer = new CommandErrorReceiver ( );
            if ( Device.BusyBox.Available ) {
                Device.ExecuteShellCommand ( "busybox mount {0}", cer, mountPoint );
            } else {
                Device.ExecuteShellCommand ( "mount {0}", cer, mountPoint );
            }
        }