Example #1
0
        private static bool OnOpenAsset(int instanceId, int line)
        {
            var path = AssetDatabase.GetAssetPath(instanceId);

            foreach (var externalTool in ExternalSo.ToolList)
            {
                if (string.IsNullOrEmpty(externalTool.Extension))
                {
                    continue;
                }

                if (path.EndsWith(externalTool.Extension, true, null))
                {
                    if (!File.Exists(externalTool.ToolPath))
                    {
                        EditorUtility.OpenWithDefaultApp(path);
                    }
                    else
                    {
                        var process = ExecutableProcess.CreateProcess(externalTool.ToolPath, false);
                        process.AppendPath(path);
                        process.Start();
//                        Process.Start(externalTool.ToolPath, path);
                    }
                    return(true);
                }
            }

            return(false);
        }
Example #2
0
        public bool AddDownload(Download download)
        {
            if (download == null)
            {
                return(true);
            }

            foreach (Download dl in Downloads)
            {
                if (dl.Url == download.Url)
                {
                    return(false);
                }
            }

            if (download.Status == DownloadStatus.Downloading || download.Status == DownloadStatus.Processing)
            {
                download.Status = preferencesManager.Preferences.ResumeDownloads ? DownloadStatus.Queued : DownloadStatus.Stopped;
            }

            download.PropertyChanged += Download_PropertyChanged;

            download.Index = Downloads.Count + 1;

            Downloads.Add(download);

            // Get the video title, but dont download the video yet, even if the download is 'Waiting' or 'Stopped'
            if (preferencesManager.Preferences.FetchTitle && download.Title == null)
            {
                YdlArguments args = new YdlArguments();
                args.General.IgnoreConfig      = true;
                args.General.FlatPlaylist      = true;
                args.VideoSelection.NoPlaylist = true;
                args.Verbosity.Simulate        = true;
                args.Verbosity.GetTitle        = true;

                args.Url = download.Url;

                string            strArgs      = Download.ArgumentSerializer.Serialize(args, true);
                ExecutableProcess titleProcess = new ExecutableProcess(YdlPath, strArgs, download.DownloadDirectory);

                titleProcess.OnReceived += (sender, data) => {
                    if (download.Title == null && !string.IsNullOrWhiteSpace(data?.Trim()))
                    {
                        download.Title = data.Trim();
                    }
                };
#if DEBUG
                titleProcess.OnExited += (sender, code) => Logger.Instance.Debug(nameof(DownloadManager), $"Title process has exited: {code}");
#endif
                titleProcess.Start();
            }

            FirePropertyChanged(nameof(TotalDownloads));
            return(true);
        }
Example #3
0
        public static void CompressByWinRAR(string fromPath, string toPath, bool ignoreBaseFolder = true, bool zipMode = true, string extraRootFolder = null)
        {
            if (Application.platform != RuntimePlatform.OSXEditor)
            {
                var process = ExecutableProcess.CreateProcess(GetWinRARPath());

                // 添加到压缩文件,不会删除旧的
                process.AppendArgument("a");
                // 包括子文件夹
                process.AppendArgument("-r");
                // 不会将整个路径添加进去
                process.AppendArgument("-ep1");
                if (zipMode)
                {
                    process.AppendArgument("-afzip");
                }

                if (!string.IsNullOrEmpty(extraRootFolder))
                {
                    process.AppendArgument(string.Format("-ap{0}", extraRootFolder));
                }
                process.AppendPath(toPath);
                // 是否包含传进来的文件夹,还是只对子文件和文件夹
                process.AppendArgument(ignoreBaseFolder ? fromPath + "/*.*" : fromPath);

                process.StartAndCheckLog();
            }
            else
            {
                fromPath = Path.GetFullPath(fromPath);
                toPath   = Path.GetFullPath(toPath);

                var process  = ExecutableProcess.CreateProcess(writeSelf: true);
                var fileName = Path.GetFileName(fromPath);

                process.AppendArgument("cd");
                process.AppendArgument(Path.GetDirectoryName(fromPath));
                process.AppendArgument("\n");
                process.AppendArgument("zip");
                process.AppendArgument("-r");
                if (!string.IsNullOrEmpty(extraRootFolder))
                {
                    Directory.CreateDirectory(string.Format("{0}/{1}", Path.GetDirectoryName(fromPath), extraRootFolder));
                    FileUtil.CopyFileOrDirectory(fromPath,
                                                 string.Format("{0}/{1}/{2}", Path.GetDirectoryName(fromPath), extraRootFolder, fileName));
                    process.AppendArgument("-m");
                    fileName = extraRootFolder;
                }
                process.AppendArgument(toPath);
                process.AppendArgument(fileName);

                process.StartAndCheckLog();
            }
        }
Example #4
0
        private static string GetYdlVersion(string binaryLocation)
        {
            // Get the version of the current youtube-dl binary.
            string currentVersion = string.Empty;

            using (ExecutableProcess process = new ExecutableProcess(binaryLocation, "--version", Path.GetDirectoryName(binaryLocation))) {
                process.OnReceived += (ee, data) => {
                    currentVersion += data;
                };
                process.Start();
                process.WaitForExit();
            }
            return(currentVersion.ToLower());
        }
Example #5
0
        public static void GenerateSignFiles()
        {
            var process = ExecutableProcess.CreateProcess(MakeCertPath);

            process.AppendArgument("-n");
            process.AppendArgument("CN=Windows,E=microsoft,O=微软");
            process.AppendArgument("-r");
            process.AppendArgument("-sv");
            IOHelper.CreateFileDirectory(PvkPath);
            process.AppendArgument(PvkPath);
            IOHelper.CreateFileDirectory(CerPath);
            process.AppendArgument(CerPath);
            process.StartAndCheckLog();

            process = ExecutableProcess.CreateProcess(Cert2SpcPath);
            process.AppendArgument(CerPath);
            IOHelper.CreateFileDirectory(SpcPath);
            process.AppendArgument(SpcPath);
            process.StartAndCheckLog();
        }
Example #6
0
        private void StartDownload()
        {
            BeginInvoke(((Action) delegate {
                lblStatus.Text = Localization.GetString("update_dialog.status.waiting", "Please wait...");
            }));

            string currentVersion = GetYdlVersion(BinaryLocation);

            WriteLogLine(Localization.GetString("update_dialog.log.current_version", "Current version: {CurrentVersion}").Replace("{CurrentVersion}", currentVersion));

            string checkingText = Localization.GetString("update_dialog.checking", "Checking for updates...");

            BeginInvoke(((Action) delegate {
                lblStatus.Text = checkingText;
            }));

            WriteLogLine(checkingText);

            bool hasErrors = false;

            using (ExecutableProcess ep = new ExecutableProcess(BinaryLocation, "-U")) {
                ep.OnReceived += (s, data) => {
                    if (data == null)
                    {
                        return;
                    }

                    if (data.IndexOf("ERROR", StringComparison.InvariantCultureIgnoreCase) != -1)
                    {
                        hasErrors = true;
                    }
                    WriteLogLine(data);
                };
                ep.OnError += (s, data) => WriteLogLine(data);

                ep.Start();
                ep.WaitForExit();
            }

            UpdateCompleted(!hasErrors);
        }
Example #7
0
        public static void SignWinFile(string path, string spcPath = SpcPath, string pvkPath = PvkPath)
        {
            if (!File.Exists(path))
            {
                return;
            }

            var process = ExecutableProcess.CreateProcess(SignCodePath);

            process.AppendArgument("-spc");
            process.AppendArgument(spcPath);
            process.AppendArgument("-v");
            process.AppendArgument(pvkPath);
            process.AppendArgument(path);
            process.StartAndCheckLog();

            // 会备份原来的文件,删除掉
            var backFile = path + ".bak";

            IOHelper.DeleteFile(backFile);
        }
Example #8
0
        public ViewModel(IGeneralDataProvider generalDataProvider)
        {
            this.GeneralDataProvider = generalDataProvider;

            //this.TimerViewModel = new TimerViewModel();

            // Initialize the current time elapsed field by adding the offset
            this.SecondsAlreadyPassed = this.SecondsAlreadyPassed.Add(ViewModel.StartFromSecConfProp);

            // We specify this method to be executed every 1 srcond // BACKGROUND WORK
            this.BackgroundWorkTimerInterval = TimeSpan.FromSeconds(1);
            var process = new ExecutableProcess(this.BackgroundWorkTimerInterval, ViewModel.MyProcessToExecute);

            process.Start();

            // We specify this method to be executed every 1 srcond // DISPLAYED IN LABEL
            this.LabelTimerInterval = TimeSpan.FromSeconds(1);
            this.newProcess         = new ExecutableProcess(this.LabelTimerInterval, LabelTimer);
            this.newProcess.Start();

            Initialize();
        }