Example #1
0
        /// <summary>
        ///     Uninstall modded files specified in the InstallPath from the users console, ignore game specific files as this
        ///     could cause game to stop working (only .sprx files)
        /// </summary>
        /// <param name="ipAddress">Mod to uninstall</param>
        /// <param name="remoteFile">Mod to uninstall</param>
        /// <param name="modItem">Mod to uninstall</param>
        internal static void DownloadOriginalGameFile(string ipAddress, string remoteFile, ModsData.ModItem modItem)
        {
            /*foreach (var installFilePath in modInfo.InstallPaths)
             * {
             *  using (var ps3 = new FtpConnection(ipAddress))
             *  {
             *      if (ps3.FileExists(installFilePath) && !installFilePath.StartsWith("dev_hdd0/game/{REGION}/", StringComparison.InvariantCultureIgnoreCase))
             *          ps3.RemoveFile(installFilePath);
             *  }
             * }*/

            using (FtpConnection ps3 = new FtpConnection(ipAddress))
            {
                string dirPath = remoteFile.Contains("/")
                    ? remoteFile.Substring(0, remoteFile.LastIndexOf('/')) + '/'
                    : "dev_hdd0/";

                string fileName = remoteFile.Contains("/")
                    ? remoteFile.Substring(remoteFile.LastIndexOf('/')).Replace("/", "").Replace("//", "")
                    : remoteFile;

                string localFilePath = $@"{AppDataPath}{modItem.GameId}\{modItem.Name}\";

                Directory.CreateDirectory(localFilePath);

                ps3.SetCurrentDirectory(dirPath);
                ps3.GetFile(remoteFile, $@"{localFilePath}{fileName}".Replace("/", @"\"), false);
                //ps3.PutFile(localFile, fileName);
            }
        }
Example #2
0
        /// <summary>
        /// Downloads the specified console file to the computer
        /// </summary>
        /// <param name="filePath"> Path of the uploading file directory </param>
        internal static bool FileExists(string filePath)
        {
            FtpConnection ftpConnection = MainWindow.FtpConnection;

            string parentDirectory = Path.GetDirectoryName(filePath).Replace(@"\", "/");

            ftpConnection.SetCurrentDirectory(parentDirectory);

            return(ftpConnection.FileExists(filePath));
        }
Example #3
0
        /// <summary>
        /// Downloads the specified console file to the computer
        /// </summary>
        /// <param name="filePath">Path of the uploading file directory</param>
        internal static bool FileExists(string filePath)
        {
            FtpConnection ftpConnection = MainWindow.FtpConnection;

            string dirPath = filePath.Contains("/")
                ? filePath.Substring(0, filePath.LastIndexOf('/')) + '/'
                : "dev_hdd0/";

            ftpConnection.SetCurrentDirectory(dirPath);

            return(ftpConnection.FileExists(filePath));
        }
Example #4
0
        internal static void UploadFile(string localFile, string consoleFile)
        {
            FtpConnection ftpConnection = MainWindow.FtpConnection;

            string path       = consoleFile.Contains("/") ? (consoleFile.Substring(0, consoleFile.LastIndexOf('/')) + "/") : "dev_hdd0/";
            string remoteFile = consoleFile.Contains("/") ? consoleFile.Substring(consoleFile.LastIndexOf('/')).Replace("/", "").Replace("//", "") : consoleFile;

            if (!ftpConnection.DirectoryExists(path))
            {
                CreateDirectory(path);
            }

            ftpConnection.SetCurrentDirectory(path);
            ftpConnection.PutFile(localFile, remoteFile);
        }
Example #5
0
        /// <summary>
        ///     Upload the specified local file to the appropriate location on the console
        /// </summary>
        /// <param name="ipAddress">PS3 IP address</param>
        /// <param name="localFile">Path of the local file</param>
        /// <param name="consoleFile">Path of the uploading file directory</param>
        internal static void InstallFile(string ipAddress, string localFile, string consoleFile)
        {
            using (FtpConnection ps3 = new FtpConnection(ipAddress))
            {
                var fileName = consoleFile.Contains("/")
                    ? consoleFile.Substring(consoleFile.LastIndexOf('/')).Replace("/", "").Replace("//", "")
                    : consoleFile;

                var dirPath = consoleFile.Contains("/")
                    ? consoleFile.Substring(0, consoleFile.LastIndexOf('/')) + '/'
                    : "dev_hdd0/";

                ps3.SetCurrentDirectory(dirPath);
                ps3.PutFile(localFile, fileName);
            }
        }
Example #6
0
        /// <summary>
        ///     Upload a local file to the specified location on the console
        /// </summary>
        /// <param name="ftpConnection">PS3 IP address</param>
        /// <param name="localFile">Path of the local file</param>
        /// <param name="consoleFile">Path of the uploading file directory</param>
        internal static void UploadFile(FtpConnection ftpConnection, string localFile, string consoleFile)
        {
            string dirPath = consoleFile.Contains("/")
                    ? consoleFile.Substring(0, consoleFile.LastIndexOf('/')) + '/'
                    : "dev_hdd0/";

            string fileName = consoleFile.Contains("/")
                    ? consoleFile.Substring(consoleFile.LastIndexOf('/')).Replace("/", "").Replace("//", "")
                    : consoleFile;

            if (!ftpConnection.DirectoryExists(dirPath))
            {
                CreateDirectory(dirPath);
            }

            ftpConnection.SetCurrentDirectory(dirPath);
            ftpConnection.PutFile(localFile, fileName);
        }
Example #7
0
        /// <summary>
        /// Gets the folder names inside the specified console path
        /// </summary>
        /// <param name="consolePath">Path of the uploading file directory</param>
        internal static List <string> GetFolderNames(string consolePath)
        {
            FtpConnection ftpConnection = MainWindow.FtpConnection;

            List <string> folderNames = new List <string>();

            string dirPath = consolePath.Contains("/")
                ? consolePath.Substring(0, consolePath.LastIndexOf('/')) + '/'
                : "/dev_hdd0/";

            ftpConnection.SetCurrentDirectory(dirPath);

            foreach (FtpDirectoryInfo directoryInfo in ftpConnection.GetDirectories(dirPath).Skip(2))
            {
                folderNames.Add(directoryInfo.Name);
            }

            return(folderNames);
        }
Example #8
0
        /// <summary>
        /// Downloads the specified console file to the computer
        /// </summary>
        /// <param name="localFile">Path of the local file</param>
        /// <param name="consoleFile">Path of the uploading file directory</param>
        internal static void DownloadFile(string localFile, string consoleFile)
        {
            FtpConnection ftpConnection = MainWindow.FtpConnection;

            string dirPath = consoleFile.Contains("/")
                ? consoleFile.Substring(0, consoleFile.LastIndexOf('/')) + '/'
                : "dev_hdd0/";

            ftpConnection.SetLocalDirectory(Path.GetDirectoryName(localFile));
            ftpConnection.SetCurrentDirectory(dirPath);

            if (File.Exists(localFile))
            {
                File.Delete(localFile);
            }

            if (FileExists(consoleFile))
            {
                ftpConnection.GetFile(consoleFile, localFile, false);
            }
        }
Example #9
0
        /// <summary>
        /// Downloads the specified console file to the computer
        /// </summary>
        /// <param name="localFile"> Path of the local file </param>
        /// <param name="consoleFile"> Path of the uploading file directory </param>
        internal static void DownloadFile(string localFile, string consoleFile)
        {
            FtpConnection ftpConnection = MainWindow.FtpConnection;

            Program.Log.Info("Local file: " + localFile);
            Program.Log.Info("Console file: " + consoleFile);

            string parentDirectory = Path.GetDirectoryName(consoleFile).Replace(@"\", "/");

            ftpConnection.SetLocalDirectory(Path.GetDirectoryName(localFile));
            ftpConnection.SetCurrentDirectory(parentDirectory);

            if (File.Exists(localFile))
            {
                File.Delete(localFile);
            }

            if (FileExists(consoleFile))
            {
                ftpConnection.GetFile(consoleFile, localFile, false);
            }
        }