Ejemplo n.º 1
0
        /// <summary>
        /// Changes the current configuration with the specified <paramref name="name"/>
        /// and/or <paramref name="address"/>, and raises an event to notify of the change.
        /// </summary>
        /// <param name="name">
        /// [Optional] The new name as which to try reaching the device.
        /// </param>
        /// <param name="address">
        /// [Optional] The new address at which the device can be reached.
        /// </param>
        public void ChangeConfig(string name = null, string address = null)
        {
            var config = _config.With(name, address);

            _config = config;
            OnConfigChanged?.Invoke(this, config);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Moves a file from the specified <paramref name="sourcePath"/> to the specified
        /// <paramref name="targetPath"/> on the Raspberry Pi device with the specified
        /// <paramref name="rpiConfig"/>. The local file with path <paramref name="sourcePath"/>
        /// will be deleted.
        /// </summary>
        /// <param name="sourcePath">
        /// The path to the file to be moved.
        /// </param>
        /// <param name="targetPath">
        /// The path to which the file will be moved.
        /// </param>
        /// <param name="rpiConfig">
        /// The configuration of the device to which the file will be moved.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// When one or more of the required parameters are <c>null</c>.
        /// </exception>
        public void MoveFile(string sourcePath, string targetPath, RpiConfig rpiConfig)
        {
            if (string.IsNullOrEmpty(sourcePath))
            {
                throw new ArgumentNullException(nameof(sourcePath));
            }

            if (string.IsNullOrEmpty(targetPath))
            {
                throw new ArgumentNullException(nameof(targetPath));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Copies a file from the specified <paramref name="sourcePath"/> to the specified
        /// <paramref name="targetPath"/> on the Raspberry Pi device with the specified
        /// <paramref name="rpiConfig"/>.
        /// </summary>
        /// <param name="sourcePath">
        /// The path to the file to be copied.
        /// </param>
        /// <param name="targetPath">
        /// The path to which the file will be copied.
        /// </param>
        /// <param name="rpiConfig">
        /// The configuration of the device to which the file will be copied.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// When one or more of the required parameters are <c>null</c>.
        /// </exception>
        public void CopyFile(string sourcePath, string targetPath, RpiConfig rpiConfig)
        {
            if (string.IsNullOrEmpty(sourcePath))
            {
                throw new ArgumentNullException(sourcePath);
            }

            if (string.IsNullOrEmpty(targetPath))
            {
                throw new ArgumentNullException(nameof(targetPath));
            }

            var source = EscapeWindowsPath(sourcePath);
            var target = EscapeUnixPath($"{rpiConfig.ConnectionString}:~/{targetPath}");

            _cmdExecutor.Execute($"{CopyCommand} {source} {target}");
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Moves a directory from the specified <paramref name="sourcePath"/> to the specified
        /// <paramref name="targetPath"/> with all of its subdirectories and files to the
        /// specifeid <paramref name="targetPath"/> on the Rasperry Pi device with the
        /// specified <paramref name="rpiConfig"/>.
        /// </summary>
        /// <param name="sourcePath">
        /// The path to the directory to be moved.
        /// </param>
        /// <param name="targetPath">
        /// The path to which the directory will be moved.
        /// </param>
        /// <param name="rpiConfig">
        /// The configuration of the device to which the directory will be moved.
        /// </param>
        /// <remarks>
        /// This operation will delete the directory and all subdirectories and files from <paramref name="sourcePath"/>.
        /// </remarks>
        public void MoveDirectory(string sourcePath, string targetPath, RpiConfig rpiConfig)
        {
            if (string.IsNullOrEmpty(sourcePath))
            {
                throw new ArgumentNullException(sourcePath);
            }

            if (string.IsNullOrEmpty(targetPath))
            {
                throw new ArgumentNullException(nameof(targetPath));
            }

            var dir   = new DirectoryInfo(sourcePath);
            var files = dir.GetFiles(AllFilesFilter, new EnumerationOptions()
            {
                RecurseSubdirectories = true
            });

            foreach (var file in files)
            {
                string target = file.FullName.Replace(sourcePath, targetPath);
            }
        }