public void MoveDirectory_Source_DirectoryName_DestinationDirectoryName_UIOptionOverwriteFalse()
        {
            var FullPathToSourceDirectory = System.IO.Path.Combine(TestDirectory, "SourceDirectory");
            var FullPathToTargetDirectory = System.IO.Path.Combine(TestDirectory, "TargetDirectory");

            System.IO.Directory.CreateDirectory(FullPathToSourceDirectory);
            for (int i = 0; i < 6; i++)
            {
                CreateTestFile(SourceData, PathFromBase: "SourceDirectory", TestFileName: $"Select_Skip_this_file{i}");
            }
            System.IO.Directory.CreateDirectory(FullPathToTargetDirectory);
            var NewFile0WithPath = CreateTestFile(DestData, PathFromBase: "TargetDirectory", TestFileName: "Select_Skip_this_file0");

            FileIO.FileSystem.MoveDirectory(FullPathToSourceDirectory, FullPathToTargetDirectory, showUI: UIOption.AllDialogs, onUserCancel: UICancelOption.ThrowException);
            string[] RemainingSourceFilesWithPath = System.IO.Directory.GetFiles(FullPathToSourceDirectory);
            // We couldn't move one file
            Assert.Equal(1, RemainingSourceFilesWithPath.Length);
            // Ensure the file left has correct data
            Assert.True(HasExpectedData(RemainingSourceFilesWithPath[0], SourceData));

            string[] DestinationFilesWithPath = System.IO.Directory.GetFiles(FullPathToTargetDirectory);
            Assert.Equal(6, DestinationFilesWithPath.Length);
            foreach (var CurrentFile in DestinationFilesWithPath)
            {
                Assert.True(HasExpectedData(CurrentFile, CurrentFile.EndsWith("0") ? DestData : SourceData));
            }
        }
示例#2
0
        public virtual bool BuildOculus()
        {
            List <string> BuiltDesktopFiles = new List <string>();

            BuiltDesktopFiles.AddRange(IgorCore.GetModuleProducts());

            string OculusDirectToRiftFilename = "";

            foreach (string CurrentFile in BuiltDesktopFiles)
            {
                if (CurrentFile.EndsWith(".exe"))
                {
                    OculusDirectToRiftFilename = CurrentFile.Replace(".exe", "_DirectToRift.exe");
                }
            }

            if (File.Exists(OculusDirectToRiftFilename))
            {
                BuiltDesktopFiles.Add(OculusDirectToRiftFilename);
            }

            IgorCore.SetNewModuleProducts(BuiltDesktopFiles);

            return(true);
        }
        public void CopyDirectory_SourceDirectoryName_DestinationDirectoryName_OverwriteFalse()
        {
            var FullPathToSourceDirectory = System.IO.Path.Combine(TestDirectory, "SourceDirectory");
            var FullPathToTargetDirectory = System.IO.Path.Combine(TestDirectory, "TargetDirectory");

            System.IO.Directory.CreateDirectory(FullPathToSourceDirectory);
            for (int i = 0; i < 6; i++)
            {
                CreateTestFile(SourceData, PathFromBase: "SourceDirectory", TestFileName: $"NewFile{i}");
            }
            FileIO.FileSystem.CopyDirectory(FullPathToSourceDirectory, FullPathToTargetDirectory, overwrite: false);
            Assert.Equal(System.IO.Directory.GetFiles(FullPathToSourceDirectory).Length, System.IO.Directory.GetFiles(FullPathToTargetDirectory).Length);
            foreach (var CurrentFile in System.IO.Directory.GetFiles(FullPathToTargetDirectory))
            {
                // Ensure copy transferred written data
                Assert.True(HasExpectedData(CurrentFile, SourceData));
            }
            System.IO.Directory.Delete(FullPathToTargetDirectory, recursive: true);
            System.IO.Directory.CreateDirectory(FullPathToTargetDirectory);
            CreateTestFile(DestData, PathFromBase: "TargetDirectory", TestFileName: $"NewFile0");
            Assert.Throws <System.IO.IOException>(() => FileIO.FileSystem.CopyDirectory(FullPathToSourceDirectory, FullPathToTargetDirectory, overwrite: false));
            Assert.Equal(System.IO.Directory.GetFiles(FullPathToTargetDirectory).Length, System.IO.Directory.GetFiles(FullPathToSourceDirectory).Length);
            foreach (var CurrentFile in System.IO.Directory.GetFiles(FullPathToTargetDirectory))
            {
                Assert.True(HasExpectedData(CurrentFile, CurrentFile.EndsWith("0") ? DestData : SourceData));
            }
        }
示例#4
0
        public virtual void CopyJavaFilesAndReplacePackageName(string RootSourceDir, string RootDestDir)
        {
            List <string> JavaFilesToCopy = IgorRuntimeUtils.GetListOfFilesAndDirectoriesInDirectory(RootSourceDir, true, false, true, true, true);

            foreach (string CurrentFile in JavaFilesToCopy)
            {
                if (CurrentFile.EndsWith(".java") || CurrentFile.EndsWith(".aidl"))
                {
                    string RelativeFilePath   = CurrentFile.Substring(RootSourceDir.Length + 1);
                    string NewDestinationPath = Path.Combine(RootDestDir, RelativeFilePath);

                    if (!Directory.Exists(Path.GetDirectoryName(NewDestinationPath)))
                    {
                        Directory.CreateDirectory(Path.GetDirectoryName(NewDestinationPath));
                    }

                    if (!File.Exists(NewDestinationPath))
                    {
                        IgorRuntimeUtils.CopyFile(CurrentFile, NewDestinationPath);

                        IgorUtils.ReplaceStringsInFile(this, NewDestinationPath, "com.facebook.android.R", PlayerSettings.bundleIdentifier + ".R");
                        IgorUtils.ReplaceStringsInFile(this, NewDestinationPath, "import com.facebook.android.*;", "import com.facebook.android.*;\nimport " + PlayerSettings.bundleIdentifier + ".R;");
                        IgorUtils.ReplaceStringsInFile(this, NewDestinationPath, "com.facebook.android.BuildConfig", PlayerSettings.bundleIdentifier + ".BuildConfig");
                        IgorUtils.ReplaceStringsInFile(this, NewDestinationPath, "import com.mikamikem.AndroidUnity.R;", "import " + PlayerSettings.bundleIdentifier + ".R;");
                    }
                }
            }
        }
示例#5
0
 internal void Populate()
 {
     if (CurrentFile.EndsWith(".DC", StringComparison.InvariantCultureIgnoreCase))
     {
     }
     else if (CurrentFile.EndsWith(".IS", StringComparison.InvariantCultureIgnoreCase))
     {
     }
 }
示例#6
0
        /// <summary>
        /// Saves the currently open file to the filename that it was opened from.
        /// If the file was not originally .dzb, SaveAs() is invoked instead.
        /// </summary>
        /// <returns>Returns a bool specifiying if the save operation was successful</returns>
        public bool Save()
        {
            if (!CurrentFile.EndsWith("dzb"))
            {
                SaveAs();

                return true;
            }

            Export(CurrentFile);

            return true;
        }
        public void CopyDirectory_SourceDirectoryName_DestinationDirectoryName_SkipFile()
        {
            var FullPathToSourceDirectory = System.IO.Path.Combine(TestDirectory, "SourceDirectory");
            var FullPathToTargetDirectory = System.IO.Path.Combine(TestDirectory, "TargetDirectory");

            System.IO.Directory.CreateDirectory(FullPathToSourceDirectory);
            for (int i = 0; i < 6; i++)
            {
                CreateTestFile(SourceData, PathFromBase: "SourceDirectory", TestFileName: $"Select_Skip_this_file{i}");
            }
            System.IO.Directory.CreateDirectory(FullPathToTargetDirectory);
            CreateTestFile(DestData, PathFromBase: "TargetDirectory", TestFileName: $"Select_Skip_this_file0");
            FileIO.FileSystem.CopyDirectory(FullPathToSourceDirectory, FullPathToTargetDirectory, UIOption.AllDialogs, onUserCancel: UICancelOption.ThrowException);
            Assert.Equal(System.IO.Directory.GetFiles(FullPathToTargetDirectory).Length, System.IO.Directory.GetFiles(FullPathToSourceDirectory).Length);
            foreach (var CurrentFile in System.IO.Directory.GetFiles(FullPathToTargetDirectory))
            {
                Assert.True(HasExpectedData(CurrentFile, CurrentFile.EndsWith("0") ? DestData : SourceData));
            }
        }
示例#8
0
        public void MoveDirectory_SourceDirectoryName_DestinationDirectoryName_OverwriteFalse()
        {
            var FullPathToSourceDirectory = System.IO.Path.Combine(TestDirectory, "SourceDirectory");
            var FullPathToTargetDirectory = System.IO.Path.Combine(TestDirectory, "TargetDirectory");

            System.IO.Directory.CreateDirectory(FullPathToSourceDirectory);
            for (int i = 0; i < 6; i++)
            {
                CreateTestFile(SourceData, PathFromBase: "SourceDirectory", TestFileName: $"NewFile{i}");
            }

            _fileSystem.MoveDirectory(FullPathToSourceDirectory, FullPathToTargetDirectory, overwrite: false);
            Assert.Equal(6, System.IO.Directory.GetFiles(FullPathToTargetDirectory).Length);
            Assert.False(System.IO.Directory.Exists(FullPathToSourceDirectory));
            foreach (var CurrentFile in System.IO.Directory.GetFiles(FullPathToTargetDirectory))
            {
                // Ensure move transferred written data
                Assert.True(HasExpectedData(CurrentFile, SourceData));
            }

            System.IO.Directory.Move(FullPathToTargetDirectory, FullPathToSourceDirectory);
            System.IO.Directory.CreateDirectory(FullPathToTargetDirectory);
            var NewFile0WithPath = CreateTestFile(DestData, PathFromBase: "TargetDirectory", TestFileName: "NewFile0");

            Assert.Throws <System.IO.IOException>(() => _fileSystem.MoveDirectory(FullPathToSourceDirectory, FullPathToTargetDirectory, overwrite: false));
            string[] RemainingSourceFilesWithPath = System.IO.Directory.GetFiles(FullPathToSourceDirectory);
            // We couldn't move one file
            Assert.Single(RemainingSourceFilesWithPath);
            // Ensure the file left has correct data
            Assert.True(HasExpectedData(RemainingSourceFilesWithPath[0], SourceData));

            string[] DestinationFilesWithPath = System.IO.Directory.GetFiles(FullPathToTargetDirectory);
            Assert.Equal(6, DestinationFilesWithPath.Length);
            foreach (var CurrentFile in DestinationFilesWithPath)
            {
                Assert.True(HasExpectedData(CurrentFile, CurrentFile.EndsWith("0") ? DestData : SourceData));
            }
        }
示例#9
0
        public static List <string> GetListOfFilesAndDirectoriesInDirectory(string RootDir, bool bFiles = true, bool bDirectories = true, bool bRecursive = false, bool bFilterOutUnitySpecialFiles = true, bool bAbsolutePath = false)
        {
            List <string> FilesAndDirs = new List <string>();

            string[] Results = { };

            if (bFiles)
            {
                FilesAndDirs.AddRange(Directory.GetFiles(RootDir, "*", bRecursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly));
            }

            if (bDirectories)
            {
                FilesAndDirs.AddRange(Directory.GetDirectories(RootDir, "*", bRecursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly));
            }

            Results = FilesAndDirs.ToArray();

            FilesAndDirs.Clear();

            foreach (string CurrentFile in Results)
            {
                if (!bFilterOutUnitySpecialFiles || (!CurrentFile.EndsWith(".meta") && !CurrentFile.EndsWith("~") && !CurrentFile.EndsWith(".class")))
                {
                    string RequestedPath = CurrentFile;

                    if (!bAbsolutePath)
                    {
                        RequestedPath = RequestedPath.Replace(Path.GetFullPath(RootDir) + Path.DirectorySeparatorChar, "");
                    }

                    FilesAndDirs.Add(RequestedPath);
                }
            }

            return(FilesAndDirs);
        }