Esempio n. 1
0
        public static List <XciItem> GetSdXcis()
        {
            List <XciItem> xciList = new List <XciItem>();

            if (Directory.Exists(Settings.config.sdDriveLetter))
            {
                xciList = XciHelper.LoadGamesFromPath(Settings.config.sdDriveLetter, recurse: true, isSdCard: true);
            }

            return(xciList);
        }
Esempio n. 2
0
        public static List <XciItem> GetSdXcis()
        {
            List <XciItem> xciList = new List <XciItem>();

            if (Directory.Exists(Settings.config.sdDriveLetter))
            {
                // SD card games are currently only in the root directory (for SX OS)
                xciList = XciHelper.LoadGamesFromPath(Settings.config.sdDriveLetter, recurse: false, isSdCard: true);
            }

            return(xciList);
        }
Esempio n. 3
0
        public static List <XciItem> GetPcXcis()
        {
            List <XciItem> xciList = new List <XciItem>();

            foreach (string path in Settings.config.localXciFolders)
            {
                xciList.AddRange(XciHelper.LoadGamesFromPath(path, recurse: true, isSdCard: false));
            }

            //xciList = XciHelper.CreateMasterXciList(xciList, xciOnSd);

            return(xciList);
        }
Esempio n. 4
0
        internal static void RebuildCache()
        {
            if (IsFileTransferInProgress())
            {
                return;
            }

            lock (cacheListLock)
                xciCache = new List <XciItem>();

            File.Delete(Settings.cacheFileName);
            XciHelper.LoadXcisInBackground();
        }
Esempio n. 5
0
        public static List <XciItem> LoadGamesFromPath(string dirPath, bool recurse = true, bool isSdCard = false)
        {
            List <XciItem> pathXciList = new List <XciItem>();
            //ulong packageId;
            string  uniqueId;
            XciItem xciTemp;

            Log($"LoadGamesFromPath: {dirPath}");
            List <string> xciFileList = FindAllFiles(dirPath, recurse);

            foreach (var item in xciFileList)
            {
                uniqueId = XciHelper.GetXciIdentifier(item);
                //Log($"LoadGamesFromPath: {uniqueId} - {item}");

                // Check if this game is in the Cache and Clone the cache XciItem to decouple the objects
                lock (cacheListLock)
                    xciTemp = Clone(XciHelper.FindXciByIdentifer(uniqueId));

                if (xciTemp == null)
                {
                    xciTemp = new XciItem();
                }
                else
                {
                    xciTemp.keepInCache = true;
                }

                xciTemp.xciFilePath = "";

                xciTemp.isGameOnSd = isSdCard;
                xciTemp.isGameOnPc = !isSdCard;

                if (isSdCard)
                {
                    xciTemp.xciLocation = XciLocation.SD;
                }
                else
                {
                    xciTemp.xciLocation = XciLocation.PC;
                }

                xciTemp.xciFilePath = item;

                pathXciList.Add(xciTemp);
            }

            return(pathXciList);
        }
        private static void TransferWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            //todo check if enough space on destination for transfer
            formMain.SetupProgressBar(0, 100, 0);

            XciItem xciAction;

            totalFiles       = xciTransfers.Count();
            transferredFiles = 0;

            while (xciTransfers.Count > 0)
            {
                lock (lockObject)
                    xciAction = xciTransfers.First();

                customCopy = new CustomFileCopy(xciAction.fileAction.sourcePath, xciAction.fileAction.destinationPath);

                customCopy.OnProgressChanged += CustomCopy_OnProgressChanged;
                customCopy.OnComplete        += CustomCopy_OnComplete;

                formMain.UpdateProgressLabel($"Copying {Path.GetFileName(xciAction.fileAction.sourcePath)} [{transferredFiles}/{totalFiles}]");

                customCopy.Copy();

                transferredFiles++;

                lock (lockObject)
                    xciTransfers.Remove(xciAction);

                xciAction.fileAction.actionCompleted = true;

                if (transferWorker.CancellationPending)
                {
                    File.Delete(xciAction.fileAction.destinationPath); //delete the destination if we cancelled early
                    e.Cancel = true;
                    return;
                }

                xciAction.fileAction.actionSuccess = true;
                XciHelper.UpdateXci(xciAction);
            }
        }