public static IConverter GetConverter(SupportedExtensions extension)
        {
            IConverter converter = null;

            switch (extension)
            {
            case SupportedExtensions.doc:
            case SupportedExtensions.docx:
                converter = new WordToPdfConverter();
                break;

            case SupportedExtensions.ppt:
            case SupportedExtensions.pptx:
                converter = new PowerPointToPdfConverter();
                break;

            case SupportedExtensions.xls:
            case SupportedExtensions.xlsx:
                converter = new ExcelToHtmlConverter();
                break;

            case SupportedExtensions.rtf:
                converter = new RtfToPdfConverter();
                break;

            case SupportedExtensions.eml:
            case SupportedExtensions.msg:
                converter = new MailToHtmlConverter();
                break;
            }
            return(converter);
        }
Пример #2
0
        /// <summary>
        /// Gets image format of image file.
        /// </summary>
        /// <param name="imagePath">Path to image file.</param>
        /// <returns>Format of image.</returns>
        public static Format ParseFormat(string imagePath, ref DDS_HEADER header)
        {
            SupportedExtensions ext = ParseExtension(imagePath);

            using (FileStream fs = new FileStream(imagePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                return(ParseFormat(fs, ext, ref header));
        }
Пример #3
0
        public SoundSourceSelector()
        {
            InitializeComponent();

            AllowDrop  = true;
            DragEnter += (s, e) =>
            {
                e.Effect = DragDropEffects.None;
                if (!e.Data.GetDataPresent(DataFormats.FileDrop))
                {
                    return;
                }

                var items = (string[])e.Data.GetData(DataFormats.FileDrop);
                if (items.Length != 1)
                {
                    return;
                }

                string path = items.Single();
                if (SupportedExtensions.Any(p => Path.GetExtension(path) == p) && File.Exists(path))
                {
                    e.Effect = DragDropEffects.Copy;
                }
            };
            DragDrop += (s, e) =>
            {
                filePathBox.Text = ((string[])e.Data.GetData(DataFormats.FileDrop)).Single();
            };
        }
Пример #4
0
        public ImageLoader(object FileDir)
        {
            _root = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);  // Get full exe app location on disk.

            var DirPath = Path.Combine(Root, FileDir.ToString());

            if (Directory.Exists(DirPath))  // Check if directory is exists.
            {
                _supportedExtensions = new[] { ".bmp", ".jpeg", ".jpg", ".png" };
                _isCatched           = true;
                _files = Directory.GetFiles(Path.Combine(Root, FileDir.ToString()), "*.*").Where
                             ((ext) => SupportedExtensions.Contains(Path.GetExtension(ext).ToLower()));

                _imageSources = new List <ImageSource>();
                foreach (var file in Files)
                {
                    BitmapImage BMP = new BitmapImage();
                    BMP.BeginInit();
                    BMP.CacheOption = BitmapCacheOption.OnLoad;
                    BMP.UriSource   = new Uri(file, UriKind.Absolute);
                    BMP.EndInit();
                    BMP.Freeze();

                    _imageSources.Add(BMP);
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Collects all of the data that needs to be indexed as defined in the index set.
        /// </summary>
        /// <param name="node">Media item XML being indexed</param>
        /// <param name="type">Type of index (should only ever be media)</param>
        /// <returns>Fields containing the data for the index</returns>
        protected override Dictionary <string, string> GetDataToIndex(XElement node, string type)
        {
            var fields = base.GetDataToIndex(node, type);

            //find the field which contains the file
            XElement fileElement = node.Elements().FirstOrDefault(x =>
            {
                if (x.Attribute("alias") != null)
                {
                    return((string)x.Attribute("alias") == this.UmbracoFileProperty);
                }
                else
                {
                    return(x.Name == this.UmbracoFileProperty);
                }
            });

            //make sure the file exists
            if (fileElement != default(XElement) && !string.IsNullOrEmpty(fileElement.Value))
            {
                // Parse the current value
                string filePath = fileElement.Value;
                if ((filePath).StartsWith("{"))
                {
                    filePath = JObject.Parse(filePath).Value <string>("src");
                }

                if (!filePath.IsNullOrWhiteSpace())
                {
                    // Get the file path from the data service
                    string fullPath = this.DataService.MapPath(filePath);
                    var    fi       = new FileInfo(fullPath);
                    if (fi.Exists)
                    {
                        try
                        {
                            if (!SupportedExtensions.Select(x => x.ToUpper()).Contains(fi.Extension.ToUpper()))
                            {
                                DataService.LogService.AddInfoLog((int)node.Attribute("id"), "UmbracoExamine.FileIndexer: Extension '" + fi.Extension + "' is not supported at this time");
                            }
                            else
                            {
                                fields.Add(TextContentFieldName, ExtractTextFromFile(fi));
                            }
                        }
                        catch (Exception ex)
                        {
                            DataService.LogService.AddErrorLog((int)node.Attribute("id"), "An error occurred: " + ex);
                        }
                    }
                    else
                    {
                        DataService.LogService.AddInfoLog((int)node.Attribute("id"), "UmbracoExamine.FileIndexer: No file found at path " + filePath);
                    }
                }
            }

            return(fields);
        }
Пример #6
0
        /// <summary>
        /// Determines image type via headers.
        /// Keeps stream position.
        /// </summary>
        /// <param name="imgData">Image data, incl header.</param>
        /// <returns>Type of image.</returns>
        public static SupportedExtensions DetermineImageType(Stream imgData)
        {
            SupportedExtensions ext = SupportedExtensions.UNKNOWN;

            // KFreon: Save position and go back to start
            long originalPos = imgData.Position;

            imgData.Seek(0, SeekOrigin.Begin);

            var bits = new byte[8];

            imgData.Read(bits, 0, 8);

            // BMP
            if (BMP_Header.CheckIdentifier(bits))
            {
                ext = SupportedExtensions.BMP;
            }

            // PNG
            if (PNG_Header.CheckIdentifier(bits))
            {
                ext = SupportedExtensions.PNG;
            }

            // JPG
            if (JPG_Header.CheckIdentifier(bits))
            {
                ext = SupportedExtensions.JPG;
            }

            // DDS
            if (DDS_Header.CheckIdentifier(bits))
            {
                ext = SupportedExtensions.DDS;
            }

            // GIF
            if (GIF_Header.CheckIdentifier(bits))
            {
                ext = SupportedExtensions.GIF;
            }

            if (TIFF_Header.CheckIdentifier(bits))
            {
                ext = SupportedExtensions.TIF;
            }

            // TGA (assumed if no other matches
            if (ext == SupportedExtensions.UNKNOWN)
            {
                ext = SupportedExtensions.TGA;
            }

            // KFreon: Reset stream position
            imgData.Seek(originalPos, SeekOrigin.Begin);

            return(ext);
        }
Пример #7
0
        public bool IsSupportedExtension(string extension)
        {
            if (SupportedExtensions == null || SupportedExtensions.Count == 0)
            {
                return(true);
            }

            return(SupportedExtensions.Contains(extension));
        }
Пример #8
0
        private void ParseSupportedFileExtensions(XmlDocument doc)
        {
            ConfigurationFile.GetDefaultSupportedFileExtensions().ForEach(ext => SupportedExtensions.Add(ext));

            foreach (XmlElement e in doc.SelectNodes("/ccm/fileExtensions/fileExtension"))
            {
                SupportedExtensions.Add(e.InnerText);
            }
        }
Пример #9
0
        /// <summary>
        ///     Adds the extension to the supported extensions.
        /// </summary>
        /// <param name="extensionName">Name of the extension.</param>
        protected void AddExtension(string extensionName)
        {
            if (SupportedExtensions == null)
            {
                SupportedExtensions = new PxExtensionNamesClass();
            }

            SupportedExtensions.Add(extensionName);
        }
Пример #10
0
        public static void ParseMetadata(
            DirectoryInfo inputDirectory,
            DirectoryInfo jsonOutputDirectory,
            string sqliteFilepath,
            bool exportSqlite,
            bool exportJson,
            bool shouldOverwrite)
        {
            var files      = inputDirectory.EnumerateFiles();
            var validFiles = files.Where(n => SupportedExtensions.Contains(n.Extension));
            var fileTagMap = new Dictionary <string, IDictionary <string, IEnumerable <string> > >();

            foreach (var file in validFiles)
            {
                var         path    = file.FullName;
                TagLib.File tagFile = null;
                try
                {
                    tagFile = TagLib.File.Create(path);
                }
                catch (Exception)
                {
                    // TODO: Add Logging
                    continue;
                }

                if (tagFile.GetTag(TagLib.TagTypes.Xiph) is TagLib.Ogg.XiphComment xiph)
                {
                    IDictionary <string, IEnumerable <string> > tagMap = xiph.ToDictionary(
                        fieldName => fieldName,
                        fieldName => xiph.GetField(fieldName).AsEnumerable());

                    fileTagMap.Add(file.Name, tagMap);
                    continue;
                }

                if (tagFile.GetTag(TagLib.TagTypes.Id3v2) is TagLib.Id3v2.Tag id3File)
                {
                    IDictionary <string, IEnumerable <string> > tagMap = GetID3v2TagMap(id3File);
                    fileTagMap.Add(file.Name, tagMap);
                    continue;
                }
            }

            if (fileTagMap.Any())
            {
                if (exportSqlite)
                {
                    ExportSqlite(fileTagMap, sqliteFilepath);
                }

                if (exportJson)
                {
                    ExportJson(fileTagMap, jsonOutputDirectory, shouldOverwrite);
                }
            }
        }
Пример #11
0
        /// <summary>
        /// Gets image format from stream containing image file, along with extension of image file.
        /// </summary>
        /// <param name="imgData">Stream containing entire image file. NOT just pixels.</param>
        /// <param name="extension">Extension of image file.</param>
        /// <returns>Format of image.</returns>
        public static Format ParseFormat(Stream imgData, string extension, ref DDS_HEADER header)
        {
            SupportedExtensions ext = SupportedExtensions.UNKNOWN;

            // KFreon: Attempt to determine from data
            if (extension == null)
            {
                // KFreon: Save position and go back to start
                long originalPos = imgData.Position;
                imgData.Seek(0, SeekOrigin.Begin);

                char l1 = (char)imgData.ReadByte();
                char l2 = (char)imgData.ReadByte();
                char l3 = (char)imgData.ReadByte();
                char l4 = (char)imgData.ReadByte();

                // BMP
                if (l1 == 'B' && l2 == 'M')
                {
                    ext = SupportedExtensions.BMP;
                }

                // PNG
                if (l1 == 137 && l2 == 'P' && l3 == 'N' && l4 == 'G')
                {
                    ext = SupportedExtensions.PNG;
                }

                // JPG
                if (l1 == 0xFF && l2 == 0xD8 && l3 == 0xFF)
                {
                    ext = SupportedExtensions.JPG;
                }

                // DDS
                if (l1 == 'D' && l2 == 'D' && l3 == 'S')
                {
                    ext = SupportedExtensions.DDS;
                }

                // KFreon: Reset stream position
                imgData.Seek(originalPos, SeekOrigin.Begin);
            }
            else
            {
                ext = ParseExtension(extension);
            }

            if (ext == SupportedExtensions.UNKNOWN)
            {
                return(new Format());
            }

            return(ParseFormat(imgData, ext, ref header));
        }
Пример #12
0
        /// <summary>
        /// Gets file extension from string of extension.
        /// </summary>
        /// <param name="extension">String containing file extension.</param>
        /// <returns>SupportedExtension of extension.</returns>
        public static SupportedExtensions ParseExtension(string extension)
        {
            SupportedExtensions ext = SupportedExtensions.DDS;
            string tempext          = extension.Contains('.') ? Path.GetExtension(extension).Replace(".", "") : extension;

            if (!Enum.TryParse(tempext, true, out ext))
            {
                return(SupportedExtensions.UNKNOWN);
            }

            return(ext);
        }
Пример #13
0
        private void buttonBrowse_Click(object sender, EventArgs e)
        {
            var wildcards = SupportedExtensions.Select(p => "*" + p);
            var dialog    = new OpenFileDialog()
            {
                Filter = FileFilterStrings.AudioFilter + string.Format("({0})|{1}", string.Join(", ", wildcards), string.Join(";", wildcards))
            };

            if (dialog.ShowDialog(this) == DialogResult.OK)
            {
                filePathBox.Text = dialog.FileName;
            }
        }
Пример #14
0
        /// <summary>
        /// need to prevent extensions not in allowed extensions getting into the index
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        private bool IsAllowedExtension(XElement node)
        {
            var extension = node.Element("umbracoExtension");

            if (extension != null)
            {
                var extensionValue = "." + extension.Value;
                if (SupportedExtensions.Select(x => x.ToUpper()).Contains(extensionValue.ToUpper()))
                {
                    return(true);
                }
            }
            return(false);
        }
        /// <summary>
        /// Provides the means to extract the text to be indexed from the file specified
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        protected virtual string ExtractTextFromFile(FileInfo file)
        {
            if (!SupportedExtensions.Select(x => x.ToUpper()).Contains(file.Extension.ToUpper()))
            {
                throw new NotSupportedException("The file with the extension specified is not supported");
            }

            var pdf = new PDFParserPdfBox();

            Action <Exception> onError = (e) => OnIndexingError(new IndexingErrorEventArgs("Could not read PDF", -1, e));

            var txt = pdf.GetTextFromAllPages(file.FullName, onError);

            return(txt);
        }
Пример #16
0
        /// <summary>
        /// Provides the means to extract the text to be indexed from the file specified
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        protected virtual string ExtractTextFromFile(FileInfo file)
        {
            if (!SupportedExtensions.Select(x => x.ToUpper()).Contains(file.Extension.ToUpper()))
            {
                throw new NotSupportedException("The file with the extension specified is not supported");
            }

            var mediaParser = new MediaParser();

            Action <Exception> onError = (e) => OnIndexingError(new IndexingErrorEventArgs("Could not read media item", -1, e));

            var txt = mediaParser.ParseMediaText(file.FullName, onError, out _extractedMetaFromTika);

            return(txt);
        }
Пример #17
0
        static FontCollection LoadSystemFonts()
        {
            // TODO: currently only supports Windows
            var collection = new FontCollection();

            foreach (var file in Directory.EnumerateFiles(Environment.GetFolderPath(Environment.SpecialFolder.Fonts)))
            {
                if (SupportedExtensions.Contains(Path.GetExtension(file).ToLowerInvariant()))
                {
                    collection.AddFontFile(file, throwOnError: false);
                }
            }

            return(collection);
        }
Пример #18
0
        private static async void SourcePropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            if (e.OldValue is string oldFilePath && PreviewedFilePaths.Contains(oldFilePath))
            {
                PreviewedFilePaths.Remove(oldFilePath);
            }

            if (obj is Image image)
            {
                if (e.NewValue is string filePath && !String.IsNullOrEmpty(filePath))
                {
                    FileInfo file = new FileInfo(filePath);
                    if (file.Exists && SupportedExtensions.Any(x => x.OrdinalEquals(file.Extension)))
                    {
                        try
                        {
                            image.Tag = filePath;
                            PreviewedFilePaths.Add(filePath);

                            int hashCode = image.GetHashCode();
                            if (!ImageReferences.ContainsKey(hashCode))
                            {
                                ImageReferences.Add(hashCode, new WeakReference <Image>(image));
                                image.Unloaded += (x, y) => { PreviewedFilePaths.Remove(image.Tag?.ToString()); };
                            }

                            if (file.Length > 1048576)
                            {
                                image.Visibility = Visibility.Collapsed;
                            }

                            image.Tag    = file.FullName;
                            image.Source = await ReadImageAsync(file.FullName);
                        }
                        finally
                        {
                            image.Visibility = Visibility.Visible;
                        }
                    }
                }
                else
                {
                    image.Tag    = null;
                    image.Source = null;
                }
            }
Пример #19
0
        /// <summary>
        /// try read file, if failed, return message of error
        /// </summary>
        /// <param name="file_name">text.txt</param>
        /// <param name = "wanted_extension">selected extension</param>
        /// <returns>line that contains useful info</returns>
        public static string ReadContentFile(string file_name, SupportedExtensions wanted_extension)
        {
            try
            {
                byte index_of_content = 0;
                switch (wanted_extension)
                {
                case (SupportedExtensions.txt): index_of_content = 0; break;

                case (SupportedExtensions.html): index_of_content = 2; break;

                case (SupportedExtensions.fb2): index_of_content = 7; break;
                }
                return(File.ReadAllLines(CorrectFileName(file_name, wanted_extension), Encoding.Unicode)[index_of_content]);
            }
            catch (Exception e) { return("Reading failed!" + "\r\n" + e.GetType() + "\r\n" + e.Message); };
        }
Пример #20
0
        public StringBuilder BuildControl(string filePhysicalPath, string fileVirtualPath, string tempDirectoryPhysicalPath,
                                          string tempDirectoryVirtualPath, string appDomain, string appRootUrl)
        {
            try
            {
                string fileExtension          = Path.GetExtension(fileVirtualPath);
                string frameSource            = fileVirtualPath;
                SupportedExtensions extension = (SupportedExtensions)Enum.Parse(typeof(SupportedExtensions), fileExtension.Replace(".", ""));
                IConverter          converter = ConverterFactory.GetConverter(extension);
                if (converter != null)
                {
                    string tempFileName = converter.Convert(filePhysicalPath, tempDirectoryPhysicalPath);
                    if (string.IsNullOrEmpty(tempFileName))
                    {
                        throw new Exception("An error ocurred while trying to convert the file");
                    }

                    frameSource = string.Format("{0}/{1}", tempDirectoryVirtualPath, tempFileName);
                }

                if (PdfRenderer == PdfRenderers.PdfJs && Enum.IsDefined(typeof(PdfJsSupportedExtensions), extension.ToString()))
                {
                    frameSource = string.Format("{0}{1}Scripts/pdf.js/web/viewer.html?file={0}{2}", appDomain, appRootUrl, frameSource);
                }
                else
                {
                    frameSource = string.Format("{0}/{1}", appDomain, frameSource);
                }

                StringBuilder sb = new StringBuilder();
                sb.Append("<iframe ");
                if (!string.IsNullOrEmpty(ID))
                {
                    sb.Append("id=" + ClientID + " ");
                }
                sb.Append("src=" + frameSource + " ");
                sb.Append("width=" + Width.ToString() + " ");
                sb.Append("height=" + Height.ToString() + ">");
                sb.Append("</iframe>");
                return(sb);
            }
            catch
            {
                return(new StringBuilder("Cannot display document viewer"));
            }
        }
Пример #21
0
        /// <summary>
        /// Provides the means to extract the text to be indexed from the file specified
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="mediaFileSystem"></param>
        /// <returns></returns>
        protected virtual string ExtractTextFromFile(string filePath, MediaFileSystem mediaFileSystem)
        {
            var fileExtension = mediaFileSystem.GetExtension(filePath);

            if (!SupportedExtensions.Select(x => x.ToUpper()).Contains(fileExtension.ToUpper()))
            {
                throw new NotSupportedException("The file with the extension specified is not supported");
            }

            var pdf = new PDFParser();

            Action <Exception> onError = (e) => OnIndexingError(new IndexingErrorEventArgs("Could not read PDF", -1, e));

            var txt = pdf.GetTextFromAllPages(filePath, mediaFileSystem, onError);

            return(txt);
        }
Пример #22
0
        public SoundSourceSelector()
        {
            InitializeComponent();
            AllowDrop = true;

            browseButton.Click += (s, e) =>
            {
                var wildcards = SupportedExtensions.Select(p => "*" + p);
                var dialog    = new OpenFileDialog()
                {
                    Title  = "音源選択",
                    Filter = "音声ファイル" + string.Format("({0})|{1}", string.Join(", ", wildcards), string.Join(";", wildcards))
                };
                if (dialog.ShowDialog(this) == DialogResult.OK)
                {
                    fileBox.Text = dialog.FileName;
                }
            };
        }
Пример #23
0
 protected override void putFixedParams(ByteBuffer ret)
 {
     ret.Put(_initiateTag);
     ret.Put(_adRecWinCredit);
     ret.Put((ushort)_numOutStreams);
     ret.Put((ushort)_numInStreams);
     ret.Put(_initialTSN);
     if (_cookie != null)
     {
         StateCookie sc = new StateCookie();
         sc.setData(_cookie);
         _varList.Add(sc);
     }
     if (_supportedExtensions != null)
     {
         SupportedExtensions se = new SupportedExtensions();
         se.setData(_supportedExtensions);
         _varList.Add(se);
     }
 }
Пример #24
0
        private IEnumerable <IFileSystemGallery> UpdateCurrentState()
        {
            IEnumerable <FileInfo>      archives;
            IEnumerable <DirectoryInfo> archiveFolders;

            if (_observationType.HasFlag(ObservationType.FilesRecursive))
            {
                archives = SupportedExtensions.GetFilesWithExtensions(_observedFolder, SupportedExtensions.GetArchives(), SearchOption.AllDirectories);
            }
            else if (_observationType.HasFlag(ObservationType.FilesNonRecursive))
            {
                archives = SupportedExtensions.GetFilesWithExtensions(_observedFolder, SupportedExtensions.GetArchives());
            }
            else
            {
                archives = new List <FileInfo>();
            }

            if (_observationType.HasFlag(ObservationType.FoldersRecursive))
            {
                archiveFolders = GetArchiveDirectory(_observedFolder, SupportedExtensions.GetImages(), SearchOption.AllDirectories);
            }
            else if (_observationType.HasFlag(ObservationType.FoldersNonRecursive))
            {
                archiveFolders = GetArchiveDirectory(_observedFolder, SupportedExtensions.GetImages());
            }
            else
            {
                archiveFolders = new List <DirectoryInfo>();
            }

            foreach (var archiveFolder in archiveFolders)
            {
                yield return(new FolderFileSystemGallery(archiveFolder));
            }
            foreach (var fileInfo in archives)
            {
                yield return(new ArchiveFileSystemGallery(fileInfo));
            }
        }
Пример #25
0
        /// <summary>
        /// Gets Format of image.
        /// </summary>
        /// <param name="imgData">Stream containing entire image. NOT just pixels.</param>
        /// <param name="extension">Type of file.</param>
        /// <returns>Format of image.</returns>
        public static Format ParseFormat(Stream imgData, SupportedExtensions extension, ref DDS_HEADER header)
        {
            switch (extension)
            {
            case SupportedExtensions.BMP:
                return(new Format(ImageEngineFormat.BMP));

            case SupportedExtensions.DDS:
                return(ParseDDSFormat(imgData, out header));

            case SupportedExtensions.JPG:
                return(new Format(ImageEngineFormat.JPG));

            case SupportedExtensions.PNG:
                return(new Format(ImageEngineFormat.PNG));

            case SupportedExtensions.TGA:
                return(new Format(ImageEngineFormat.TGA));
            }

            return(new Format());
        }
        public string ModuleName(string filename)
        {
            if (!_fileSystem.File.Exists(filename))
            {
                return(null);
            }

            if (!SupportedExtensions.Contains(_fileSystem.Path.GetExtension(filename)))
            {
                return(null);
            }

            var contents = _fileSystem.File.ReadLines(filename, Encoding.Default);
            var nameLine = contents.FirstOrDefault(line => line.StartsWith("Attribute VB_Name = "));

            if (nameLine == null)
            {
                return(_fileSystem.Path.GetFileNameWithoutExtension(filename));
            }

            //The format is Attribute VB_Name = "ModuleName"
            return(nameLine.Substring("Attribute VB_Name = ".Length + 1, nameLine.Length - "Attribute VB_Name = ".Length - 2));
        }
Пример #27
0
        protected override void OnDragEnter(DragEventArgs e)
        {
            base.OnDragEnter(e);
            e.Effect = DragDropEffects.None;
            if (!e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                return;
            }

            var items = (string[])e.Data.GetData(DataFormats.FileDrop);

            if (items.Length != 1)
            {
                return;
            }

            string path = items[0];

            if (SupportedExtensions.Any(p => Path.GetExtension(path) == p))
            {
                e.Effect = DragDropEffects.Copy;
            }
        }
Пример #28
0
        /// <summary>
        /// Determines image type via headers.
        /// Keeps stream position.
        /// </summary>
        /// <param name="imgData">Image data, incl header.</param>
        /// <returns>Type of image.</returns>
        public static SupportedExtensions DetermineImageType(Stream imgData)
        {
            SupportedExtensions ext = SupportedExtensions.UNKNOWN;

            // KFreon: Save position and go back to start
            long originalPos = imgData.Position;

            imgData.Seek(0, SeekOrigin.Begin);

            var bits = new byte[8];

            imgData.Read(bits, 0, 8);

            // DDS
            if (DDS_Header.CheckIdentifier(bits))
            {
                ext = SupportedExtensions.DDS;
            }

            // KFreon: Reset stream position
            imgData.Seek(originalPos, SeekOrigin.Begin);

            return(ext);
        }
 public bool SupportsExtension(string oid)
 => SupportedExtensions != null && SupportedExtensions.Contains(oid);
Пример #30
0
 public static bool BrutforceWriteFile(string wanted_file_name, string[] content, SupportedExtensions wanted_extension)
 {
     try
     {
         File.WriteAllLines(CorrectFileName(wanted_file_name, wanted_extension), content, Current_enc);
         return(true);
     } catch { return(false); }
 }