コード例 #1
0
        public static void Finalize(string destinationFolder, bool emitAssemblyList, Federation federation)
        {
            string sourcePath = Assembly.GetEntryAssembly().Location;

            sourcePath = Path.GetDirectoryName(sourcePath);
            string basePath = sourcePath;

            sourcePath = Path.Combine(sourcePath, "Web");
            if (!Directory.Exists(sourcePath))
            {
                return;
            }

            sourcePath = Path.GetFullPath(sourcePath);
            FileUtilities.CopyDirectory(sourcePath, destinationFolder);

            StampOverviewHtmlWithDate(destinationFolder);

            if (emitAssemblyList)
            {
                ToggleSolutionExplorerOff(destinationFolder);
            }

            SetExternalUrlMap(destinationFolder, federation);
        }
コード例 #2
0
        /// <summary>
        /// Installs the extension into a profile directory.
        /// </summary>
        /// <param name="profileDir">The Firefox profile directory into which to install the extension.</param>
        public void Install(string profileDir)
        {
            string tempFileName = Path.Combine(Path.GetTempPath(), this.extensionFileName);

            if (Directory.Exists(tempFileName))
            {
                Directory.Delete(tempFileName, true);
            }

            // First, expand the .xpi archive into a temporary location.
            Directory.CreateDirectory(tempFileName);
            Stream zipFileStream = ResourceUtilities.GetResourceStream(this.extensionFileName, this.extensionResourceId);

            using (ZipFile extensionZipFile = ZipFile.Read(zipFileStream))
            {
                extensionZipFile.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently;
                extensionZipFile.ExtractAll(tempFileName);
            }

            // Then, copy the contents of the temporarly location into the
            // proper location in the Firefox profile directory.
            string id = ReadIdFromInstallRdf(tempFileName);
            string extensionDirectory = Path.Combine(Path.Combine(profileDir, "extensions"), id);

            if (Directory.Exists(extensionDirectory))
            {
                Directory.Delete(extensionDirectory, true);
            }

            Directory.CreateDirectory(extensionDirectory);
            FileUtilities.CopyDirectory(tempFileName, extensionDirectory);
            Directory.Delete(tempFileName, true);
        }
コード例 #3
0
        public void Install(string profileDirectory)
        {
            DirectoryInfo directoryInfo = new DirectoryInfo(profileDirectory);
            string        text          = Path.Combine(Path.GetTempPath(), directoryInfo.Name + ".staging");
            string        text2         = Path.Combine(text, Path.GetFileName(this.extensionFileName));

            if (Directory.Exists(text2))
            {
                Directory.Delete(text2, true);
            }
            Directory.CreateDirectory(text2);
            Stream resourceStream = ResourceUtilities.GetResourceStream(this.extensionFileName, this.extensionResourceId);

            using (ZipStorer zipStorer = ZipStorer.Open(resourceStream, FileAccess.Read))
            {
                List <ZipStorer.ZipFileEntry> list = zipStorer.ReadCentralDirectory();
                foreach (ZipStorer.ZipFileEntry current in list)
                {
                    string path = current.FilenameInZip.Replace('/', Path.DirectorySeparatorChar);
                    string destinationFileName = Path.Combine(text2, path);
                    zipStorer.ExtractFile(current, destinationFileName);
                }
            }
            string path2 = FirefoxExtension.ReadIdFromInstallRdf(text2);
            string text3 = Path.Combine(Path.Combine(profileDirectory, "extensions"), path2);

            if (Directory.Exists(text3))
            {
                Directory.Delete(text3, true);
            }
            Directory.CreateDirectory(text3);
            FileUtilities.CopyDirectory(text2, text3);
            FileUtilities.DeleteDirectory(text);
        }
コード例 #4
0
        public static SQLiteConnection CreateConnection()
        {
            if (!Directory.Exists(Utilities.AppFolder))
            {
                if (CommonUtilities.Beta && Directory.Exists(Utilities.GetAppFolder(beta: false)))
                {
                    // In beta mode if we don't have the appdata folder copy the stable appdata folder
                    FileUtilities.CopyDirectory(
                        Utilities.GetAppFolder(beta: false),
                        Utilities.GetAppFolder(beta: true));
                }
                else
                {
                    Directory.CreateDirectory(Utilities.AppFolder);
                }
            }

            bool newDataFile = !File.Exists(DatabaseFile);

            var newConnection = new SQLiteConnection(ConnectionString);

            newConnection.Open();

            if (newDataFile)
            {
                CreateTables(newConnection);

                var settingsList = new Dictionary <string, string> {
                    { "Version", Utilities.CurrentDatabaseVersion.ToString(CultureInfo.InvariantCulture) }
                };
                AddSettingsList(newConnection, settingsList);
            }

            return(newConnection);
        }
コード例 #5
0
ファイル: CsPack.cs プロジェクト: vonwenm/azure-powershell
        /// <summary>
        /// Get or create a path to the role.  This is used to sanitize the
        /// contents of a role before it's packaged if it contains files that
        /// shouldn't be packaged.  We copy the contents to a temp directory,
        /// delete the offending files, and use the temp directory for
        /// packaging.  The temp directories are collected in the
        /// tempDirectories list so they can be cleaned up when packaging is
        /// complete.
        /// </summary>
        /// <remarks>
        /// This is a temporary workaround to prevent node logging information
        /// from being packaged and deployed with production applications.
        /// This method should be removed when we have a proper fix to bug
        /// https://github.com/WindowsAzure/azure-sdk-tools/issues/111
        /// </remarks>
        /// <param name="root">The root path.</param>
        /// <param name="name">Name of the role.</param>
        /// <param name="tempDirectories">
        /// A collection of temporary directories that have been created to
        /// remove files that should not be published.  This will be added to
        /// by GetOrCreateCleanPath if a new directory is created that should
        /// be cleaned up once the package has been generated.
        /// </param>
        /// <returns>
        /// A pair containing the path to the role and the name of the role.
        /// </returns>
        private static KeyValuePair <string, string> GetOrCreateCleanPath(string root, string name, Dictionary <string, string> tempDirectories, DevEnv type)
        {
            string path = Path.Combine(root, name);

            // Check if the role has any "*.logs" directories that iisnode may
            // have left during emulation
            if (type == DevEnv.Local || GetLogDirectories(path).Length == 0)
            {
                return(new KeyValuePair <string, string>(name, root));
            }
            else
            {
                // Create a temporary directory
                string tempPath = FileUtilities.CreateTempDirectory();
                tempDirectories[name] = tempPath;

                // Copy the role's directory to the temp directory
                string newPath = Path.Combine(tempPath, name);
                FileUtilities.CopyDirectory(Path.Combine(root, name), newPath);

                // Remove the offending files
                GetLogDirectories(newPath)
                .ForEach(dir => Directory.Delete(dir, true));

                return(new KeyValuePair <string, string>(name, tempPath));
            }
        }
コード例 #6
0
        private void DeployFilesToRoot(
            string destinationFolder,
            bool emitAssemblyList,
            Federation federation)
        {
            Markup.WriteReferencesNotFoundFile(destinationFolder);

            string sourcePath = Assembly.GetEntryAssembly().Location;

            sourcePath = Path.GetDirectoryName(sourcePath);
            string basePath = sourcePath;

            sourcePath = Path.Combine(sourcePath, @"Web");
            if (!Directory.Exists(sourcePath))
            {
                return;
            }

            sourcePath = Path.GetFullPath(sourcePath);
            FileUtilities.CopyDirectory(sourcePath, destinationFolder);

            StampOverviewHtmlWithDate(destinationFolder);
            if (emitAssemblyList)
            {
                ToggleSolutionExplorerOff(destinationFolder);
            }

            SetExternalUrlMap(destinationFolder, federation);

            DeployBin(basePath, destinationFolder);
        }
コード例 #7
0
        private void InitializeDirectory(string sourcePath, string targetPath, int depth = 0)
        {
            var logIndent = INDENT.Repeat(depth);

            //Console.WriteLine($"{logIndent}Initializing \"{sourcePath}\"...");

            if (!Directory.Exists(sourcePath))
            {
                return;
            }

            if (FileUtilities.IsInExcludedDirectory(sourcePath))
            {
                return;
            }

            if (!Directory.Exists(targetPath) || FileUtilities.TargetNeedsUpdate(new DirectoryInfo(sourcePath), new DirectoryInfo(targetPath)))
            {
                FileUtilities.CopyDirectory(sourcePath, targetPath, depth + 1);
            }
            else
            {
                Parallel.ForEach(FileUtilities.EnumerateDirectories(sourcePath), (subdirectory) =>
                {
                    InitializeDirectory(subdirectory.FullName, Path.Join(targetPath, subdirectory.Name), depth + 1);
                });
            }

            //Console.WriteLine($"{logIndent}Initialized \"{sourcePath}\"");
        }
コード例 #8
0
 public void OnCreated(object source, FileSystemEventArgs eventArgs)
 {
     OnEvent(eventArgs, "Created", (string sourcePath, string targetPath) =>
     {
         if (FileUtilities.IsFile(sourcePath))
         {
             FileUtilities.CopyFile(sourcePath, targetPath);
         }
         else if (FileUtilities.IsDirectory(sourcePath))
         {
             FileUtilities.CopyDirectory(sourcePath, targetPath);
         }
     });
 }
コード例 #9
0
 public void WriteToDisk()
 {
     this.profileDir = FirefoxProfile.GenerateProfileDirectoryName();
     if (!string.IsNullOrEmpty(this.sourceProfileDir))
     {
         FileUtilities.CopyDirectory(this.sourceProfileDir, this.profileDir);
     }
     else
     {
         Directory.CreateDirectory(this.profileDir);
     }
     this.InstallExtensions();
     this.DeleteLockFiles();
     this.DeleteExtensionsCache();
     this.UpdateUserPreferences();
 }
コード例 #10
0
ファイル: FirefoxExtension.cs プロジェクト: 304883563/Appium
        /// <summary>
        /// Installs the extension into a profile directory.
        /// </summary>
        /// <param name="profileDirectory">The Firefox profile directory into which to install the extension.</param>
        public void Install(string profileDirectory)
        {
            DirectoryInfo info = new DirectoryInfo(profileDirectory);
            string        stagingDirectoryName = Path.Combine(Path.GetTempPath(), info.Name + ".staging");
            string        tempFileName         = Path.Combine(stagingDirectoryName, Path.GetFileName(this.extensionFileName));

            if (Directory.Exists(tempFileName))
            {
                Directory.Delete(tempFileName, true);
            }

            // First, expand the .xpi archive into a temporary location.
            Directory.CreateDirectory(tempFileName);
            Stream zipFileStream = ResourceUtilities.GetResourceStream(this.extensionFileName, this.extensionResourceId);

            using (ZipStorer extensionZipFile = ZipStorer.Open(zipFileStream, FileAccess.Read))
            {
                List <ZipStorer.ZipFileEntry> entryList = extensionZipFile.ReadCentralDirectory();
                foreach (ZipStorer.ZipFileEntry entry in entryList)
                {
                    string localFileName   = entry.FilenameInZip.Replace('/', Path.DirectorySeparatorChar);
                    string destinationFile = Path.Combine(tempFileName, localFileName);
                    extensionZipFile.ExtractFile(entry, destinationFile);
                }
            }

            // Then, copy the contents of the temporarly location into the
            // proper location in the Firefox profile directory.
            string id = ReadIdFromInstallRdf(tempFileName);
            string extensionDirectory = Path.Combine(Path.Combine(profileDirectory, "extensions"), id);

            if (Directory.Exists(extensionDirectory))
            {
                Directory.Delete(extensionDirectory, true);
            }

            Directory.CreateDirectory(extensionDirectory);
            FileUtilities.CopyDirectory(tempFileName, extensionDirectory);

            // By deleting the staging directory, we also delete the temporarily
            // expanded extension, which we copied into the profile.
            FileUtilities.DeleteDirectory(stagingDirectoryName);
        }
コード例 #11
0
        public static void CopyOneLevelDirectoryTest()
        {
            string pathDir1      = Path.Combine(Path.GetTempPath(), "DirectoryLevel1");
            string pathDir2      = Path.Combine(pathDir1, "DirectoryLevel2");
            string pathFile1     = Path.Combine(pathDir1, "File1.txt");
            string pathFile2     = Path.Combine(pathDir2, "File2.txt");
            string pathDirTarget = Path.Combine(Path.GetTempPath(), "DirectoryTarget");

            try
            {
                Assert.IsFalse(Directory.Exists(pathDir1), "Directory level 1 must not exists at the begining");
                Assert.IsFalse(Directory.Exists(pathDir2), "Directory level 2 must not exists at the begining");
                Assert.IsFalse(File.Exists(pathFile1), "File 1 must not exists at the begining");
                Assert.IsFalse(File.Exists(pathFile2), "File 2 must not exists at the begining");
                Assert.IsFalse(Directory.Exists(pathDirTarget), "Directory target must not exists at the begining");

                Directory.CreateDirectory(pathDir1);
                Directory.CreateDirectory(pathDir2);
                File.Create(pathFile1);
                File.Create(pathFile2);

                FileUtilities.CopyDirectory(pathDir1, pathDirTarget, "*.*", true, true);

                Assert.IsTrue(Directory.Exists(pathDirTarget), "Directory level 1 was not created");
                Assert.IsTrue(Directory.Exists(Path.Combine(pathDirTarget, "DirectoryLevel1")), "Directory level 2 was not created");
                Assert.IsTrue(Directory.Exists(Path.Combine(pathDirTarget, "DirectoryLevel2")), "Directory level 2 was not created");
                Assert.IsTrue(File.Exists(Path.Combine(pathDirTarget, "DirectoryLevel1", "File1.txt")), "File level 1 was not created");
                Assert.IsTrue(File.Exists(Path.Combine(pathDirTarget, "DirectoryLevel2", "File2.txt")), "File level 2was not created");
            }
            finally
            {
                if (Directory.Exists(pathDir1))
                {
                    Directory.Delete(pathDir1, true);
                }

                if (Directory.Exists(pathDirTarget))
                {
                    Directory.Delete(pathDirTarget, true);
                }
            }
        }
コード例 #12
0
        private void DeployFilesToRoot(string destinationFolder)
        {
            Markup.WriteReferencesNotFoundFile(destinationFolder);

            string sourcePath = Assembly.GetEntryAssembly().Location;

            sourcePath = Path.GetDirectoryName(sourcePath);
            string basePath = sourcePath;

            sourcePath = Path.Combine(sourcePath, @"Web");
            if (!Directory.Exists(sourcePath))
            {
                return;
            }

            sourcePath = Path.GetFullPath(sourcePath);
            FileUtilities.CopyDirectory(sourcePath, destinationFolder);

            StampOverviewHtmlWithDate(destinationFolder);

            DeployBin(basePath, destinationFolder);
        }
コード例 #13
0
        public static void CopyEmptyDirectoryTest()
        {
            string pathDir1 = Path.Combine(Path.GetTempPath(), "EmptyDirectory1");
            string pathDir2 = Path.Combine(Path.GetTempPath(), "EmptyDirectory2");

            try
            {
                Assert.IsFalse(Directory.Exists(pathDir1), "EmptyDirectory1 must not exists at the begining");
                Assert.IsFalse(Directory.Exists(pathDir2), "EmptyDirectory2 must not exists at the begining");

                Directory.CreateDirectory(pathDir1);

                FileUtilities.CopyDirectory(pathDir1, pathDir2, "*.*", true, true);

                Assert.IsTrue(Directory.Exists(pathDir2), "EmptyDirectory2 was not created");
            }
            finally
            {
                Directory.Delete(pathDir1);
                Directory.Delete(pathDir2);
            }
        }
コード例 #14
0
        /// <summary>
        /// Installs the extension into a profile directory.
        /// </summary>
        /// <param name="profileDirectory">The Firefox profile directory into which to install the extension.</param>
        public void Install(string profileDirectory)
        {
            DirectoryInfo info = new DirectoryInfo(profileDirectory);
            string        stagingDirectoryName = Path.Combine(Path.GetTempPath(), info.Name + ".staging");
            string        tempFileName         = Path.Combine(stagingDirectoryName, Path.GetFileName(this.extensionFileName));

            if (Directory.Exists(tempFileName))
            {
                Directory.Delete(tempFileName, true);
            }

            // First, expand the .xpi archive into a temporary location.
            Directory.CreateDirectory(tempFileName);
            Stream zipFileStream = ResourceUtilities.GetResourceStream(this.extensionFileName, this.extensionResourceId);

            using (ZipArchive extensionZipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Read))
            {
                extensionZipArchive.ExtractToDirectory(tempFileName);
            }

            // Then, copy the contents of the temporarly location into the
            // proper location in the Firefox profile directory.
            string id = GetExtensionId(tempFileName);
            string extensionDirectory = Path.Combine(Path.Combine(profileDirectory, "extensions"), id);

            if (Directory.Exists(extensionDirectory))
            {
                Directory.Delete(extensionDirectory, true);
            }

            Directory.CreateDirectory(extensionDirectory);
            FileUtilities.CopyDirectory(tempFileName, extensionDirectory);

            // By deleting the staging directory, we also delete the temporarily
            // expanded extension, which we copied into the profile.
            FileUtilities.DeleteDirectory(stagingDirectoryName);
        }
コード例 #15
0
 public override IMessages Run()
 {
     return(FileUtilities.CopyDirectory(this.SourcePath, this.TargetPath, this.Filters, this.Overwrite, this.Recursive));
 }