public static IArchiveEntry AddEntry(this IWritableArchive writableArchive, string key, FileInfo fileInfo)
 {
     if (!fileInfo.Exists)
     {
         throw new ArgumentException("FileInfo does not exist.");
     }
     return writableArchive.AddEntry(key, fileInfo.OpenRead(), true, fileInfo.Length, fileInfo.LastWriteTime);
 }
Пример #2
0
        public static IMenuLink AddGroupMvcLink(this IMenu source, string linkText, string actionName, string controllerName, RouteValueDictionary routeValues, int? ordinal, IDictionary<string, object> meta)
        {
            var menuLink = new MvcActivationMenuGroup(linkText, actionName, controllerName, routeValues, ordinal, meta);

            source.AddEntry(menuLink);

            return menuLink;
        }
Пример #3
0
        public static IMenuLink AddGroupMvcRouteLink(this IMenu source, string groupText, object routeValues, int? ordinal, IDictionary<string, object> meta)
        {
            var menuLink = new MvcRouteActivationMenuGroup(groupText, routeValues, ordinal, meta);

            source.AddEntry(menuLink);

            return menuLink;
        }
Пример #4
0
        public static IMenuLink AddGroupLink(this IMenu source, string groupText, string uri, int? ordinal, IDictionary<string, object> meta)
        {
            var menuLink = new ActivationMenuGroup(groupText, uri, ordinal, meta);

            source.AddEntry(menuLink);

            return menuLink;
        }
 public static void AddEntry(this IWritableArchive writableArchive,
                                              string entryPath, string filePath)
 {
     var fileInfo = new FileInfo(filePath);
     if (!fileInfo.Exists)
     {
         throw new FileNotFoundException("Could not AddEntry: " + filePath);
     }
     writableArchive.AddEntry(entryPath, new FileInfo(filePath).OpenRead(), true, fileInfo.Length,
                              fileInfo.LastWriteTime);
 }
Пример #6
0
        public static IMenuGroup AddGroup(this IMenu source, string groupText, int? ordinal, IDictionary<string, object> meta)
        {
            if (!source.ContainsGroup(groupText))
            {
                var group = new MenuGroup(groupText, ordinal, meta);
                source.AddEntry(group);
                return group;
            }

            return source.GetGroup(groupText);
        }
        public static void AddAllFromDirectory(
            this IWritableArchive writableArchive,
            string filePath, string searchPattern = "*.*", SearchOption searchOption = SearchOption.AllDirectories)
        {
#if NET35
            foreach (var path in Directory.GetFiles(filePath, searchPattern, searchOption))
#else
            foreach (var path in Directory.EnumerateFiles(filePath, searchPattern, searchOption))
#endif
            {
                var fileInfo = new FileInfo(path);
                writableArchive.AddEntry(path.Substring(filePath.Length), fileInfo.OpenRead(), true, fileInfo.Length,
                                         fileInfo.LastWriteTime);
            }
        }
Пример #8
0
        public static IMenuLink AddGroupMvcRouteLink(this IMenu source, string groupText, string routeName, RouteValueDictionary routeValues, string protocol, string hostName, int? ordinal, IDictionary<string, object> meta)
        {
            var menuLink = new MvcRouteActivationMenuGroup(groupText, routeName, routeValues, protocol, hostName, ordinal, meta);

            source.AddEntry(menuLink);

            return menuLink;
        }
Пример #9
0
        public static Dictionary<string, string> AddSubmitInfo(this Dictionary<string,string> source, AtlasJob j, string submitCommand = "submit")
        {
            var d = new Dictionary<string, string>()
            {
            { "rm -rf /tmp/ds1-out", "" },
                { "lsetup panda", "" },
                { "mkdir /tmp/ds1-out", "" },
                { "cd /tmp/ds1-out", "" },
                { "rcSetup notmyrelease", "Found ASG release with" },
                { "echo fubar | kinit [email protected]", "Password for [email protected]: " },
                { $"rc checkout_pkg {j.Packages[0].Name}/trunk@tag", "Checked out revision" },
                { "mv trunk@tag hithere", "" },
                { "rc find_packages", "" },
                { "rc compile", "" },
                { "ls", "" },
                { "echo $?", "0" },
                { submitCommand, "dude" }
                };

            return source.AddEntry(d);
        }
        /// <summary>
        ///   Adds a File to a Zip file archive, potentially overriding the path to be
        ///   used within the zip archive.
        /// </summary>
        ///
        /// <remarks>
        /// <para>
        ///   The file added by this call to the <c>ZipFile</c> is not written to the
        ///   zip file archive until the application calls Save() on the <c>ZipFile</c>.
        /// </para>
        ///
        /// <para>
        ///   This method will throw an exception if an entry with the same name already
        ///   exists in the <c>ZipFile</c>.
        /// </para>
        ///
        /// <para>
        ///   This version of the method allows the caller to explicitly specify the
        ///   directory path to be used in the archive.
        /// </para>
        ///
        /// <para>
        ///   For <c>ZipFile</c> properties including <see cref="Encryption"/>, <see
        ///   cref="Password"/>, <see cref="SetCompression"/>, <see
        ///   cref="ProvisionalAlternateEncoding"/>, <see cref="ExtractExistingFile"/>,
        ///   <see cref="ZipErrorAction"/>, and <see cref="CompressionLevel"/>, their
        ///   respective values at the time of this call will be applied to the
        ///   <c>ZipEntry</c> added.
        /// </para>
        ///
        /// </remarks>
        ///
        /// <example>
        /// <para>
        ///   In this example, three files are added to a Zip archive. The ReadMe.txt
        ///   file will be placed in the root of the archive. The .png file will be
        ///   placed in a folder within the zip called images.  The pdf file will be
        ///   included into a folder within the zip called files\docs, and will be
        ///   encrypted with the given password.
        /// </para>
        /// <code>
        /// try
        /// {
        ///   using (ZipFile zip = new ZipFile())
        ///   {
        ///     // the following entry will be inserted at the root in the archive.
        ///     zip.AddFile("c:\\datafiles\\ReadMe.txt", "");
        ///     // this image file will be inserted into the "images" directory in the archive.
        ///     zip.AddFile("c:\\photos\\personal\\7440-N49th.png", "images");
        ///     // the following will result in a password-protected file called
        ///     // files\\docs\\2008-Regional-Sales-Report.pdf  in the archive.
        ///     zip.Password = "******";
        ///     zip.AddFile("c:\\Desktop\\2008-Regional-Sales-Report.pdf", "files\\docs");
        ///     zip.Save("Archive.zip");
        ///   }
        /// }
        /// catch (System.Exception ex1)
        /// {
        ///   System.Console.Error.WriteLine("exception: {0}", ex1);
        /// }
        /// </code>
        ///
        /// <code lang="VB">
        ///   Try
        ///       Using zip As ZipFile = New ZipFile
        ///           ' the following entry will be inserted at the root in the archive.
        ///           zip.AddFile("c:\datafiles\ReadMe.txt", "")
        ///           ' this image file will be inserted into the "images" directory in the archive.
        ///           zip.AddFile("c:\photos\personal\7440-N49th.png", "images")
        ///           ' the following will result in a password-protected file called
        ///           ' files\\docs\\2008-Regional-Sales-Report.pdf  in the archive.
        ///           zip.Password = "******"
        ///           zip.AddFile("c:\Desktop\2008-Regional-Sales-Report.pdf", "files\documents")
        ///           zip.Save("Archive.zip")
        ///       End Using
        ///   Catch ex1 As Exception
        ///       Console.Error.WriteLine("exception: {0}", ex1)
        ///   End Try
        /// </code>
        /// </example>
        ///
        /// <seealso cref="Ionic.Zip.ZipFile.AddItem(string,string)"/>
        /// <seealso cref="Ionic.Zip.ZipFile.AddDirectory(string, string)"/>
        /// <seealso cref="Ionic.Zip.ZipFile.UpdateFile(string,string)"/>
        ///
        /// <param name="fileName">
        ///   The name of the file to add.  The name of the file may be a relative path
        ///   or a fully-qualified path.
        /// </param>
        ///
        /// <param name="directoryPathInArchive">
        ///   Specifies a directory path to use to override any path in the fileName.
        ///   This path may, or may not, correspond to a real directory in the current
        ///   filesystem.  If the files within the zip are later extracted, this is the
        ///   path used for the extracted file.  Passing <c>null</c> (<c>Nothing</c> in
        ///   VB) will use the path on the fileName, if any.  Passing the empty string
        ///   ("") will insert the item at the root path within the archive.
        /// </param>
        ///
        /// <returns>The <c>ZipEntry</c> corresponding to the file added.</returns>
        public static ZipEntry AddFile(this ZipFile zipFile, string fileName, String directoryPathInArchive)
        {
            string fullPath = GetFullPath(fileName);

            string nameInArchive = ZipEntryInternal.NameInArchive(fileName, directoryPathInArchive);
            ZipEntry entry = zipFile.AddEntry(nameInArchive, (name) => {
                var file = FileSystem.Current.GetFileFromPathAsync(fullPath).ExecuteSync();
                if (file == null)
                {
                    throw new FileNotFoundException(string.Format("That file ({0}) does not exist!", fileName));
                }
                return file.OpenAsync(FileAccess.Read).ExecuteSync();
            }, (name, stream) => {
                if (stream != null)
                {
                    stream.Dispose();
                }
            });
            entry.SetLocalFileName(fullPath);
            return entry;
        }