示例#1
0
        private static void Main()
        {
            try
            {
                string lockfile = Path.Combine(IOUtils.GetAppDataDir(), "lockfile");
                File.Create(lockfile).Dispose();
                FileStream fs = File.Open(lockfile, FileMode.Open, FileAccess.ReadWrite, FileShare.None);
            }
            catch
            {
                MessageBox.Show("Another instance of Cupscale seems to be running, accessing the following data folder:\n"
                                + IOUtils.GetAppDataDir() + ".\n\nMultiple instance are only possible if they use different data folders.\n"
                                + "Starting Cupscale with \"-portable\" will use the current directory as data folder.", "Error");
                return;
            }

            Application.SetCompatibleTextRenderingDefault(defaultValue: false);
            Application.EnableVisualStyles();
            IOUtils.DeleteIfExists(Path.Combine(IOUtils.GetAppDataDir(), "sessionlog.txt"));
            Config.Init();
            Logger.Init();
            Paths.Init();
            ResourceLimits.Memory = (ulong)Math.Round(ResourceLimits.Memory * 1.5f);
            Cleanup();
            Application.Run(new MainForm());
        }
示例#2
0
 private static void Main()
 {
     Application.SetCompatibleTextRenderingDefault(defaultValue: false);
     Application.EnableVisualStyles();
     IOUtils.DeleteIfExists(Path.Combine(IOUtils.GetAppDataDir(), "sessionlog.txt"));
     Config.Init();
     Logger.Init();
     Paths.Init();
     ResourceLimits.Memory = (ulong)Math.Round(ResourceLimits.Memory * 1.5f);
     Cleanup();
     Application.Run(new MainForm());
 }
示例#3
0
 public static void Cleanup()
 {
     try
     {
         IOUtils.ClearDir(Paths.previewPath);
         IOUtils.ClearDir(Paths.previewOutPath);
         IOUtils.ClearDir(Paths.clipboardFolderPath);
         IOUtils.ClearDir(Paths.imgInPath);
         IOUtils.ClearDir(Paths.imgOutPath);
         IOUtils.ClearDir(Paths.imgOutNcnnPath);
         IOUtils.ClearDir(Paths.tempImgPath.GetParentDir());
         IOUtils.ClearDir(Path.Combine(Paths.GetDataPath(), "giftemp"));
         IOUtils.DeleteIfExists(Path.Combine(Paths.presetsPath, "lastUsed"));
         IOUtils.ClearDir(Paths.compositionOut);
         IOUtils.ClearDir(Paths.framesOutPath);
         IOUtils.DeleteIfExists(Path.Combine(Paths.GetDataPath(), "frames-out.mp4"));
     }
     catch (Exception e)
     {
         Logger.Log("Error during cleanup: " + e.Message);
     }
 }