コード例 #1
0
ファイル: Exporter.cs プロジェクト: guestnone/NilNote
 public void Start(string path)
 {
     mPath       = new NPath(path);
     mStringPath = path;
     if (!mPath.DirectoryExists())
     {
         mPath.CreateDirectory();
     }
     mPath.DeleteContents();
 }
コード例 #2
0
        private static void RecreateDagDirectoryIfNeeded(NPath dagDirectory)
        {
            var beeBackendInfoPath = dagDirectory.Combine("bee_backend.info");
            var currentInfo        = new BeeBackendInfo()
            {
                BeeBackendHash = BeeBackendHash,
                UnityVersion   = Application.unityVersion
            };

            var diskInfo = new BeeBackendInfo();

            // Clear dag directory if it was produced with a different bee_backend, to avoid problem where bee_backend sometimes looses track of files.
            if (dagDirectory.Exists())
            {
                if (beeBackendInfoPath.Exists())
                {
                    var contents = beeBackendInfoPath.ReadAllText();
                    EditorJsonUtility.FromJsonOverwrite(contents, diskInfo);

                    // Note: We're clearing dag directory only when bee backend hash has changed, it's fine for Unity version to be different.
                    //       Unity version is used here for informational purposes, so we can clearly see from which Unity version the user was upgrading
                    if (string.IsNullOrEmpty(diskInfo.BeeBackendHash) ||
                        !diskInfo.BeeBackendHash.Equals(currentInfo.BeeBackendHash))
                    {
                        Console.WriteLine($"Clearing Bee directory '{dagDirectory}', since bee backend hash ('{beeBackendInfoPath}') is different, previous hash was {diskInfo.BeeBackendHash} (Unity version: {diskInfo.UnityVersion}), current hash is {currentInfo.BeeBackendHash} (Unity version: {currentInfo.UnityVersion}).");
                        dagDirectory.Delete();
                    }
                }
                else
                {
                    Console.WriteLine($"Clearing Bee directory '{dagDirectory}', since bee backend information ('{beeBackendInfoPath}') is missing.");
                    dagDirectory.Delete();
                }
            }

            dagDirectory.CreateDirectory();

            // Update info, if at least of one the fields is different
            if (string.IsNullOrEmpty(diskInfo.BeeBackendHash) ||
                string.IsNullOrEmpty(diskInfo.UnityVersion) ||
                !diskInfo.BeeBackendHash.Equals(currentInfo.BeeBackendHash) ||
                !diskInfo.UnityVersion.Equals(currentInfo.UnityVersion))
            {
                beeBackendInfoPath.WriteAllText(EditorJsonUtility.ToJson(currentInfo, true));
            }
        }
コード例 #3
0
        public static NPath Empty(string nameSuggestion)
        {
            int num = 0;

            while (true)
            {
                string[] append    = new string[] { nameSuggestion + ((num != 0) ? num.ToString() : "") };
                NPath    directory = Il2CppTemporaryDirectoryRoot.Combine(append);
                try
                {
                    if (ForgivingCleanDirectory(directory))
                    {
                        return(directory.CreateDirectory());
                    }
                    num++;
                }
                catch (Exception)
                {
                    Console.WriteLine("Failed getting an empty tempdir at: " + directory + ", going to try again with a new name.");
                    num++;
                }
            }
        }