Esempio n. 1
0
        public App(string manifestPath, LibraryFolder directory)
        {
            this.manifestPath = manifestPath;
            this.folder       = directory;

            ACFNode appState = (ACFNode)ACFNode.ParseACF(manifestPath)["AppState"];

            this.appId          = uint.Parse(((string)appState["appid"]));
            this.appName        = (string)appState["name"];
            this.installDir     = (string)appState["installdir"];
            this.fullInstallDir = this.folder.path + "\\common\\" + installDir;
            this.appState       = int.Parse((string)appState["StateFlags"]);

            if (appState.ContainsKey("SizeOnDisk"))
            {
                sizeOnDisk = long.Parse(((string)appState["SizeOnDisk"]));
            }
            else
            {
                this.sizeOnDisk = Utils.GetDirectorySize(this.fullInstallDir);
            }
        }
Esempio n. 2
0
        public void MoveAppFiles(LibraryFolder newFolder, BackgroundWorker worker)
        {
            try
            {
                string newFullDir = newFolder.path + "\\common\\" + installDir;

                foreach (string path in Directory.GetDirectories(this.fullInstallDir, "*", SearchOption.AllDirectories))
                {
                    Directory.CreateDirectory(path.Replace(fullInstallDir, newFullDir));
                }

                foreach (string file in Directory.GetFiles(fullInstallDir, "*.*", SearchOption.AllDirectories))
                {
                    FileInfo info     = new FileInfo(file);
                    long     fileSize = info.Length;

                    File.Move(file, file.Replace(fullInstallDir, newFullDir));

                    if (worker != null && fileSize != 0)
                    {
                        worker.ReportProgress((int)Math.Round(((double)fileSize / (double)sizeOnDisk) * 1000.0f));
                    }
                }

                worker.ReportProgress(-1);

                Directory.Delete(this.fullInstallDir, true);

                this.folder         = newFolder;
                this.fullInstallDir = this.folder.path + "\\common\\" + installDir;
            }
            catch (System.IO.DirectoryNotFoundException)
            {
                return;
            }
        }