Пример #1
0
        public static void Install(string file, string source, string destinationBase, bool makeCopy = false, bool ignoreMissingFile = false)
        {
            var sourcePath      = Path.GetFullPath(Path.Combine(source, file));
            var destinationPath = Path.GetFullPath(Path.Combine(destinationBase, file));

            Directory.CreateDirectory(Directory.GetParent(destinationPath).FullName);

            if (!File.Exists(sourcePath))
            {
                if (!ignoreMissingFile)
                {
                    InfoBox.Write($"File missing: {sourcePath}", InfoBox.Level.Warning);
                }
                return;
            }

            if (makeCopy)
            {
                try
                {
                    File.Copy(sourcePath, destinationPath, false);
                }
                catch (IOException error)
                {
                    if (error.HResult != -2147024816) // ignore fileExist 0x80070050
                    {
                        InfoBox.Write($"{file} : {error.Message}", InfoBox.Level.Warning);
                    }
                }
            }
            else
            {
                SymLinker.CreateSymlink(sourcePath, destinationPath, SymLinker.SymbolicLink.File);
            }
        }
Пример #2
0
        static void CreateFolderSymLink()
        {
            DirectoryEntry selectedFolder = EditorIO.OpenFolderPanelV2("Select a folder to link into Assets");
            var            targetFolder   = EditorIO.GetAssetsFolder();

            try { targetFolder = EditorIO.GetFolderOfCurrentSelectedObject(); } catch (System.Exception) { }
            targetFolder = targetFolder.GetChildDir(selectedFolder.Name);
            SymLinker.CreateSymlink(selectedFolder, targetFolder);
            AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
        }
Пример #3
0
        static void Main(string[] args)
        {
            var x = new SymLinker();

            Console.WriteLine(x.foo());

            x.bar();
            x.foobar("string from c#");
            string another = "Another string!!!";

            x.foobar(another);
        }
Пример #4
0
        public void ExampleUsage1()
        {
            var root = EnvironmentV2.instance.GetOrAddTempFolder("SymLinkTests");

            foreach (var dir in root.GetDirectories())
            {
                dir.DeleteV2();
            }

            var f1          = root.CreateSubdirectory("Folder1");
            var targetForF1 = root.GetChildDir("TargetForFolder1");

            SymLinker.CreateSymlink(f1, targetForF1);

            const string fileName = "t1.txt";
            const string text     = "Abc";

            f1.GetChild(fileName).SaveAsText(text);

            // Check that the change in f1 also shows in the symlinked TargetForFolder1
            Assert.Equal(text, targetForF1.GetChild(fileName).LoadAs <string>());
        }