コード例 #1
0
        public SelectDirsViewModel()
        {
            _commandAdd   = new DelegateCommand(OnAddExecute);
            _commandFind  = new DelegateCommand(OnFindExecute, CanExecuteFind);
            _commandClear = new DelegateCommand(OnClearExecute, CanExecuteClear);

            Directories.CollectionChanged += (sender, args) =>
            {
                OnPropertyChanged(nameof(Directories));
            };

            _finder.DoWork += Find;
            _finder.WorkerReportsProgress = true;
            _finder.ProgressChanged      += (sender, args) => ProgressOfFinder = args.ProgressPercentage;
            _finder.RunWorkerCompleted   += (sender, args) =>
            {
                _analyzer.RunWorkerAsync(args.Result);
            };

            _analyzer.DoWork += Analyze;
            _analyzer.WorkerReportsProgress = true;
            _analyzer.ProgressChanged      += (sender, args) => ProgressOfAnalyzer = args.ProgressPercentage;
            _analyzer.RunWorkerCompleted   += (sender, args) =>
            {
                FindingIsRunning = false;
                if (args.Cancelled)
                {
                    return;
                }
                var mw = Application.Current.MainWindow as MainWindow;
                mw?.ShowResultsWindow.ApplyResults(args.Result as Results);
                mw?.GoTo(mw.ShowResultsWindow);
            };

#if DEBUG
            Directories.Add(new DirectoryData(new DirectoryInfo("C:\\Users\\lluka\\Documents\\temp\\png")));
            Directories.Add(new DirectoryData(new DirectoryInfo("C:\\Users\\lluka\\Documents\\temp\\png2")));
            OnFindExecute(null);
#endif
        }
コード例 #2
0
        public virtual FileDirectory AddDirectory(string folder)
        {
            if (!Directory.Exists(folder))
            {
                if (folder.ToLower() == "default")
                {
                    return(null);
                }
                tool.show(3, "Directory: ", "", folder, "", " Does not exist");
                return(null);
            }
            if (HasDirectory(folder))
            {
                tool.show(3, "Directory: ", "", folder, "", "Already Added");
                //todo: can return the already added fileDirectory
                return(null);
            }
            FileDirectory fd = new FileDirectory(folder);

            Directories.Add(fd);
            return(fd);
        }
コード例 #3
0
        /// <summary>
        /// Gets the directories in Directories and those nested one level deep.
        /// </summary>
        /// <returns>The directories in Directories and those nested one level deep.</returns>
        private IEnumerable <string> GetDirectoriesNestedOneLevel()
        {
            // Visit each directory in Directories Property (usually set by application)
            Directories.Add(Mono.IsRunningOnMono() ? "Mono Extensions" : "Windows Extensions");
            foreach (string directory in Directories.Union(new[] { "Data Extensions", "Tools" }))
            {
                string path = Path.Combine(BaseDirectory, directory);

                if (Directory.Exists(path))
                {
                    yield return(path);

                    // Add all of the directories in here, nested one level deep.
                    var dirs = Directory.EnumerateDirectories(path, "*", SearchOption.TopDirectoryOnly);

                    foreach (var dir in dirs)
                    {
                        yield return(dir);
                    }
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Parses the input file list and creates our internal dictionary for clearing.
        /// </summary>
        private void ParseInputFileArray()
        {
            foreach (string file in Files)
            {
                string fileName = Path.GetFileName(file);
                string filePath = file.Remove(file.LastIndexOf(fileName), fileName.Length);

                Log.LogMessage("Got path: [{0}] + file: [{1}]", filePath, fileName);

                // Add the filePath to our list of directories if it doesn't already exist.
                if (!Directories.ContainsKey(filePath))
                {
                    Directories.Add(filePath, new List <string>());
                }

                // We do not want to clear the same file more than once. One time will do.
                if (!Directories[filePath].Contains(fileName))
                {
                    Directories[filePath].Add(fileName);
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// Adds or merges a directory entry into this one.
        /// </summary>
        /// <param name="entry"></param>
        public void AddDirectory(DirectoryEntry entry)
        {
            var existingDir = Directories.FirstOrDefault(x => x.Name == entry.Name);

            if (existingDir == null)
            {
                entry._parent = this;
                Directories.Add(entry);
                return;
            }

            foreach (var dir in entry.Directories)
            {
                existingDir.AddDirectory(dir);
            }
            foreach (var file in entry.Files)
            {
                if (!existingDir.Files.Contains(file))
                {
                    existingDir.Files.Add(file);
                }
            }
        }
コード例 #6
0
        public Configuration()
        {
            Directories.Add(Environment.GetFolderPath(Environment.SpecialFolder.Desktop));

            /*
             * Directories.Add(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
             * Directories.Add(Environment.GetFolderPath(Environment.SpecialFolder.MyMusic));
             * Directories.Add(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures));
             * Directories.Add(Environment.GetFolderPath(Environment.SpecialFolder.MyVideos));
             */

            /*
             * try
             * {
             *  DriveInfo[] allDrives = DriveInfo.GetDrives();
             *
             *  foreach (DriveInfo drive in allDrives.Where(x => x.IsReady))
             *  {
             *      Directories.Add(drive.Name);
             *  }
             * }
             * catch (Exception e) { }
             */
        }
コード例 #7
0
ファイル: Directory.cs プロジェクト: AstRyou/All
 public void AddPassword()
 {
     Directories.Add(new Models.Password(Directories));
 }
コード例 #8
0
ファイル: Directory.cs プロジェクト: WilliamRagstad/CakeLang
 public void Add(Directory directory) => Directories.Add(directory);
コード例 #9
0
        public void AddHashEntry(ScsHashEntry entry)
        {
            if (entry == null)
            {
                return;
            }

            var data     = entry.Read();
            var contents = Encoding.UTF8.GetString(data);

            if (entry.IsDirectory())
            {
                var lines = contents.Split('\n');
                foreach (var line in lines) // loop through file/dir list
                {
                    if (line.Equals(""))
                    {
                        continue;
                    }

                    if (line.StartsWith("*")) // dirs
                    {
                        var dirPath = Path.Combine(EntryPath, line.Substring(1));
                        dirPath = dirPath.Replace('\\', '/');

                        var nextEntry = (ScsHashEntry)entry.GetRootFile().GetEntry(dirPath);
                        var nextHash  = CityHash.CityHash64(Encoding.UTF8.GetBytes(dirPath), (ulong)dirPath.Length);

                        if (nextEntry == null)
                        {
                            Log.Msg($"Could not find hash for '{dirPath}'");
                            continue;
                        }

                        if (!Directories.ContainsKey(nextHash))
                        {
                            var dir = new ScsDirectory(_rfs, dirPath);
                            dir.AddHashEntry(nextEntry);
                            Directories.Add(nextHash, dir);
                        }
                        else
                        {
                            Directories[nextHash].AddHashEntry(nextEntry);
                        }
                    }
                    else // file
                    {
                        var filePath = Path.Combine(EntryPath, line);
                        filePath = filePath.Replace('\\', '/');

                        var nextHash  = CityHash.CityHash64(Encoding.UTF8.GetBytes(filePath), (ulong)filePath.Length);
                        var nextEntry = entry.GetRootFile().GetEntry(filePath);

                        if (nextEntry == null)
                        {
                            Log.Msg($"Could not find hash for '{filePath}'");
                            continue;
                        }

                        if (Files.ContainsKey(nextHash))
                        {
                            // Log.Msg($"File '{filePath}' already exists => overwriting");
                            Files[nextHash] = new ScsFile(nextEntry, filePath);
                        }
                        else
                        {
                            Files.Add(nextHash, new ScsFile(nextEntry, filePath));
                        }
                    }
                }
            }
        }
コード例 #10
0
        /// <exception cref="System.IO.IOException"/>
        private bool ProcessMakernote(int makernoteOffset, [NotNull] ICollection <int> processedIfdOffsets, int tiffHeaderOffset, [NotNull] IndexedReader reader)
        {
            // Determine the camera model and makernote format.
            var ifd0Directory = Directories.OfType <ExifIfd0Directory>().FirstOrDefault();

            if (ifd0Directory == null)
            {
                return(false);
            }

            var cameraMake = ifd0Directory.GetString(ExifDirectoryBase.TagMake);

            var firstTwoChars    = reader.GetString(makernoteOffset, 2);
            var firstThreeChars  = reader.GetString(makernoteOffset, 3);
            var firstFourChars   = reader.GetString(makernoteOffset, 4);
            var firstFiveChars   = reader.GetString(makernoteOffset, 5);
            var firstSixChars    = reader.GetString(makernoteOffset, 6);
            var firstSevenChars  = reader.GetString(makernoteOffset, 7);
            var firstEightChars  = reader.GetString(makernoteOffset, 8);
            var firstTwelveChars = reader.GetString(makernoteOffset, 12);

            var byteOrderBefore = reader.IsMotorolaByteOrder;

            if ("OLYMP" == firstFiveChars || "EPSON" == firstFiveChars || "AGFA" == firstFourChars)
            {
                // Olympus Makernote
                // Epson and Agfa use Olympus makernote standard: http://www.ozhiker.com/electronics/pjmt/jpeg_info/
                PushDirectory(typeof(OlympusMakernoteDirectory));
                TiffReader.ProcessIfd(this, reader, processedIfdOffsets, makernoteOffset + 8, tiffHeaderOffset);
            }
            else if (cameraMake != null && cameraMake.ToUpper().StartsWith("MINOLTA"))
            {
                // Cases seen with the model starting with MINOLTA in capitals seem to have a valid Olympus makernote
                // area that commences immediately.
                PushDirectory(typeof(OlympusMakernoteDirectory));
                TiffReader.ProcessIfd(this, reader, processedIfdOffsets, makernoteOffset, tiffHeaderOffset);
            }
            else if (cameraMake != null && cameraMake.Trim().ToUpper().StartsWith("NIKON"))
            {
                if ("Nikon" == firstFiveChars)
                {
                    switch (reader.GetByte(makernoteOffset + 6))
                    {
                    case 1:
                    {
                        /* There are two scenarios here:
                         * Type 1:                  **
                         * :0000: 4E 69 6B 6F 6E 00 01 00-05 00 02 00 02 00 06 00 Nikon...........
                         * :0010: 00 00 EC 02 00 00 03 00-03 00 01 00 00 00 06 00 ................
                         * Type 3:                  **
                         * :0000: 4E 69 6B 6F 6E 00 02 00-00 00 4D 4D 00 2A 00 00 Nikon....MM.*...
                         * :0010: 00 08 00 1E 00 01 00 07-00 00 00 04 30 32 30 30 ............0200
                         */
                        PushDirectory(typeof(NikonType1MakernoteDirectory));
                        TiffReader.ProcessIfd(this, reader, processedIfdOffsets, makernoteOffset + 8, tiffHeaderOffset);
                        break;
                    }

                    case 2:
                    {
                        PushDirectory(typeof(NikonType2MakernoteDirectory));
                        TiffReader.ProcessIfd(this, reader, processedIfdOffsets, makernoteOffset + 18, makernoteOffset + 10);
                        break;
                    }

                    default:
                    {
                        ifd0Directory.AddError("Unsupported Nikon makernote data ignored.");
                        break;
                    }
                    }
                }
                else
                {
                    // The IFD begins with the first Makernote byte (no ASCII name).  This occurs with CoolPix 775, E990 and D1 models.
                    PushDirectory(typeof(NikonType2MakernoteDirectory));
                    TiffReader.ProcessIfd(this, reader, processedIfdOffsets, makernoteOffset, tiffHeaderOffset);
                }
            }
            else if ("SONY CAM" == firstEightChars || "SONY DSC" == firstEightChars)
            {
                PushDirectory(typeof(SonyType1MakernoteDirectory));
                TiffReader.ProcessIfd(this, reader, processedIfdOffsets, makernoteOffset + 12, tiffHeaderOffset);
            }
            else if ("SEMC MS\u0000\u0000\u0000\u0000\u0000" == firstTwelveChars)
            {
                // force MM for this directory
                reader.IsMotorolaByteOrder = true;
                // skip 12 byte header + 2 for "MM" + 6
                PushDirectory(typeof(SonyType6MakernoteDirectory));
                TiffReader.ProcessIfd(this, reader, processedIfdOffsets, makernoteOffset + 20, tiffHeaderOffset);
            }
            else if ("SIGMA\u0000\u0000\u0000" == firstEightChars || "FOVEON\u0000\u0000" == firstEightChars)
            {
                PushDirectory(typeof(SigmaMakernoteDirectory));
                TiffReader.ProcessIfd(this, reader, processedIfdOffsets, makernoteOffset + 10, tiffHeaderOffset);
            }
            else if ("KDK" == firstThreeChars)
            {
                reader.IsMotorolaByteOrder = firstSevenChars == "KDK INFO";
                var directory = new KodakMakernoteDirectory();
                Directories.Add(directory);
                ProcessKodakMakernote(directory, makernoteOffset, reader);
            }
            else if ("Canon".Equals(cameraMake, StringComparison.OrdinalIgnoreCase))
            {
                PushDirectory(typeof(CanonMakernoteDirectory));
                TiffReader.ProcessIfd(this, reader, processedIfdOffsets, makernoteOffset, tiffHeaderOffset);
            }
            else if (cameraMake != null && cameraMake.ToUpper().StartsWith("CASIO"))
            {
                if ("QVC\u0000\u0000\u0000" == firstSixChars)
                {
                    PushDirectory(typeof(CasioType2MakernoteDirectory));
                    TiffReader.ProcessIfd(this, reader, processedIfdOffsets, makernoteOffset + 6, tiffHeaderOffset);
                }
                else
                {
                    PushDirectory(typeof(CasioType1MakernoteDirectory));
                    TiffReader.ProcessIfd(this, reader, processedIfdOffsets, makernoteOffset, tiffHeaderOffset);
                }
            }
            else if ("FUJIFILM" == firstEightChars || "Fujifilm".Equals(cameraMake, StringComparison.OrdinalIgnoreCase))
            {
                // Note that this also applies to certain Leica cameras, such as the Digilux-4.3
                reader.IsMotorolaByteOrder = false;
                // the 4 bytes after "FUJIFILM" in the makernote point to the start of the makernote
                // IFD, though the offset is relative to the start of the makernote, not the TIFF
                // header (like everywhere else)
                var ifdStart = makernoteOffset + reader.GetInt32(makernoteOffset + 8);
                PushDirectory(typeof(FujifilmMakernoteDirectory));
                TiffReader.ProcessIfd(this, reader, processedIfdOffsets, ifdStart, makernoteOffset);
            }
            else if ("KYOCERA" == firstSevenChars)
            {
                // http://www.ozhiker.com/electronics/pjmt/jpeg_info/kyocera_mn.html
                PushDirectory(typeof(KyoceraMakernoteDirectory));
                TiffReader.ProcessIfd(this, reader, processedIfdOffsets, makernoteOffset + 22, tiffHeaderOffset);
            }
            else if ("LEICA" == firstFiveChars)
            {
                reader.IsMotorolaByteOrder = false;
                if ("Leica Camera AG" == cameraMake)
                {
                    PushDirectory(typeof(LeicaMakernoteDirectory));
                    TiffReader.ProcessIfd(this, reader, processedIfdOffsets, makernoteOffset + 8, tiffHeaderOffset);
                }
                else if ("LEICA" == cameraMake)
                {
                    // Some Leica cameras use Panasonic makernote tags
                    PushDirectory(typeof(PanasonicMakernoteDirectory));
                    TiffReader.ProcessIfd(this, reader, processedIfdOffsets, makernoteOffset + 8, tiffHeaderOffset);
                }
                else
                {
                    return(false);
                }
            }
            else if ("Panasonic\u0000\u0000\u0000" == reader.GetString(makernoteOffset, 12))
            {
                // NON-Standard TIFF IFD Data using Panasonic Tags. There is no Next-IFD pointer after the IFD
                // Offsets are relative to the start of the TIFF header at the beginning of the EXIF segment
                // more information here: http://www.ozhiker.com/electronics/pjmt/jpeg_info/panasonic_mn.html
                PushDirectory(typeof(PanasonicMakernoteDirectory));
                TiffReader.ProcessIfd(this, reader, processedIfdOffsets, makernoteOffset + 12, tiffHeaderOffset);
            }
            else if ("AOC\u0000" == firstFourChars)
            {
                // NON-Standard TIFF IFD Data using Casio Type 2 Tags
                // IFD has no Next-IFD pointer at end of IFD, and
                // Offsets are relative to the start of the current IFD tag, not the TIFF header
                // Observed for:
                // - Pentax ist D
                PushDirectory(typeof(CasioType2MakernoteDirectory));
                TiffReader.ProcessIfd(this, reader, processedIfdOffsets, makernoteOffset + 6, makernoteOffset);
            }
            else if (cameraMake != null && (cameraMake.ToUpper().StartsWith("PENTAX") || cameraMake.ToUpper().StartsWith("ASAHI")))
            {
                // NON-Standard TIFF IFD Data using Pentax Tags
                // IFD has no Next-IFD pointer at end of IFD, and
                // Offsets are relative to the start of the current IFD tag, not the TIFF header
                // Observed for:
                // - PENTAX Optio 330
                // - PENTAX Optio 430
                PushDirectory(typeof(PentaxMakernoteDirectory));
                TiffReader.ProcessIfd(this, reader, processedIfdOffsets, makernoteOffset, makernoteOffset);
            }
//          else if ("KC" == firstTwoChars || "MINOL" == firstFiveChars || "MLY" == firstThreeChars || "+M+M+M+M" == firstEightChars)
//          {
//              // This Konica data is not understood.  Header identified in accordance with information at this site:
//              // http://www.ozhiker.com/electronics/pjmt/jpeg_info/minolta_mn.html
//              // TODO add support for minolta/konica cameras
//              exifDirectory.addError("Unsupported Konica/Minolta data ignored.");
//          }
            else if ("SANYO\x0\x1\x0" == firstEightChars)
            {
                PushDirectory(typeof(SanyoMakernoteDirectory));
                TiffReader.ProcessIfd(this, reader, processedIfdOffsets, makernoteOffset + 8, makernoteOffset);
            }
            else if (cameraMake != null && cameraMake.ToLower().StartsWith("ricoh"))
            {
                if (firstTwoChars == "Rv" || firstThreeChars == "Rev")
                {
                    // This is a textual format, where the makernote bytes look like:
                    //   Rv0103;Rg1C;Bg18;Ll0;Ld0;Aj0000;Bn0473800;Fp2E00:������������������������������
                    //   Rv0103;Rg1C;Bg18;Ll0;Ld0;Aj0000;Bn0473800;Fp2D05:������������������������������
                    //   Rv0207;Sf6C84;Rg76;Bg60;Gg42;Ll0;Ld0;Aj0004;Bn0B02900;Fp10B8;Md6700;Ln116900086D27;Sv263:0000000000000000000000��
                    // This format is currently unsupported
                    return(false);
                }
                if (firstFiveChars.Equals("Ricoh", StringComparison.OrdinalIgnoreCase))
                {
                    // Always in Motorola byte order
                    reader.IsMotorolaByteOrder = true;
                    PushDirectory(typeof(RicohMakernoteDirectory));
                    TiffReader.ProcessIfd(this, reader, processedIfdOffsets, makernoteOffset + 8, makernoteOffset);
                }
            }
            else
            {
                // The makernote is not comprehended by this library.
                // If you are reading this and believe a particular camera's image should be processed, get in touch.
                return(false);
            }
            reader.IsMotorolaByteOrder = byteOrderBefore;
            return(true);
        }
コード例 #11
0
        /// <exception cref="System.IO.IOException"/>
        private bool ProcessMakernote(int makernoteOffset, [NotNull] ICollection <int> processedIfdOffsets, [NotNull] IndexedReader reader)
        {
            Debug.Assert(makernoteOffset >= 0, "makernoteOffset >= 0");

            var cameraMake = Directories.OfType <ExifIfd0Directory>().FirstOrDefault()?.GetString(ExifDirectoryBase.TagMake);

            var firstTwoChars    = reader.GetString(makernoteOffset, 2, Encoding.UTF8);
            var firstThreeChars  = reader.GetString(makernoteOffset, 3, Encoding.UTF8);
            var firstFourChars   = reader.GetString(makernoteOffset, 4, Encoding.UTF8);
            var firstFiveChars   = reader.GetString(makernoteOffset, 5, Encoding.UTF8);
            var firstSixChars    = reader.GetString(makernoteOffset, 6, Encoding.UTF8);
            var firstSevenChars  = reader.GetString(makernoteOffset, 7, Encoding.UTF8);
            var firstEightChars  = reader.GetString(makernoteOffset, 8, Encoding.UTF8);
            var firstTenChars    = reader.GetString(makernoteOffset, 10, Encoding.UTF8);
            var firstTwelveChars = reader.GetString(makernoteOffset, 12, Encoding.UTF8);

            if (string.Equals("OLYMP\0", firstSixChars, StringComparison.Ordinal) ||
                string.Equals("EPSON", firstFiveChars, StringComparison.Ordinal) ||
                string.Equals("AGFA", firstFourChars, StringComparison.Ordinal))
            {
                // Olympus Makernote
                // Epson and Agfa use Olympus makernote standard: http://www.ozhiker.com/electronics/pjmt/jpeg_info/
                PushDirectory(new OlympusMakernoteDirectory());
                TiffReader.ProcessIfd(this, reader, processedIfdOffsets, makernoteOffset + 8);
            }
            else if (string.Equals("OLYMPUS\0II", firstTenChars, StringComparison.Ordinal))
            {
                // Olympus Makernote (alternate)
                // Note that data is relative to the beginning of the makernote
                // http://exiv2.org/makernote.html
                PushDirectory(new OlympusMakernoteDirectory());
                TiffReader.ProcessIfd(this, reader.WithShiftedBaseOffset(makernoteOffset), processedIfdOffsets, 12);
            }
            else if (cameraMake != null && cameraMake.StartsWith("MINOLTA", StringComparison.OrdinalIgnoreCase))
            {
                // Cases seen with the model starting with MINOLTA in capitals seem to have a valid Olympus makernote
                // area that commences immediately.
                PushDirectory(new OlympusMakernoteDirectory());
                TiffReader.ProcessIfd(this, reader, processedIfdOffsets, makernoteOffset);
            }
            else if (cameraMake != null && cameraMake.TrimStart().StartsWith("NIKON", StringComparison.OrdinalIgnoreCase))
            {
                if (string.Equals("Nikon", firstFiveChars, StringComparison.Ordinal))
                {
                    switch (reader.GetByte(makernoteOffset + 6))
                    {
                    case 1:
                    {
                        /* There are two scenarios here:
                         * Type 1:                  **
                         * :0000: 4E 69 6B 6F 6E 00 01 00-05 00 02 00 02 00 06 00 Nikon...........
                         * :0010: 00 00 EC 02 00 00 03 00-03 00 01 00 00 00 06 00 ................
                         * Type 3:                  **
                         * :0000: 4E 69 6B 6F 6E 00 02 00-00 00 4D 4D 00 2A 00 00 Nikon....MM.*...
                         * :0010: 00 08 00 1E 00 01 00 07-00 00 00 04 30 32 30 30 ............0200
                         */
                        PushDirectory(new NikonType1MakernoteDirectory());
                        TiffReader.ProcessIfd(this, reader, processedIfdOffsets, makernoteOffset + 8);
                        break;
                    }

                    case 2:
                    {
                        PushDirectory(new NikonType2MakernoteDirectory());
                        TiffReader.ProcessIfd(this, reader.WithShiftedBaseOffset(makernoteOffset + 10), processedIfdOffsets, 8);
                        break;
                    }

                    default:
                    {
                        Error("Unsupported Nikon makernote data ignored.");
                        break;
                    }
                    }
                }
                else
                {
                    // The IFD begins with the first Makernote byte (no ASCII name).  This occurs with CoolPix 775, E990 and D1 models.
                    PushDirectory(new NikonType2MakernoteDirectory());
                    TiffReader.ProcessIfd(this, reader, processedIfdOffsets, makernoteOffset);
                }
            }
            else if (string.Equals("SONY CAM", firstEightChars, StringComparison.Ordinal) ||
                     string.Equals("SONY DSC", firstEightChars, StringComparison.Ordinal))
            {
                PushDirectory(new SonyType1MakernoteDirectory());
                TiffReader.ProcessIfd(this, reader, processedIfdOffsets, makernoteOffset + 12);
            }
            // Do this check LAST after most other Sony checks
            else if (cameraMake != null && cameraMake.StartsWith("SONY", StringComparison.Ordinal) &&
                     reader.GetBytes(makernoteOffset, 2) != new byte[] { 0x01, 0x00 })
            {
                // The IFD begins with the first Makernote byte (no ASCII name). Used in SR2 and ARW images
                PushDirectory(new SonyType1MakernoteDirectory());
                TiffReader.ProcessIfd(this, reader, processedIfdOffsets, makernoteOffset);
            }
            else if (string.Equals("SEMC MS\u0000\u0000\u0000\u0000\u0000", firstTwelveChars, StringComparison.Ordinal))
            {
                // Force Motorola byte order for this directory
                // skip 12 byte header + 2 for "MM" + 6
                PushDirectory(new SonyType6MakernoteDirectory());
                TiffReader.ProcessIfd(this, reader.WithByteOrder(isMotorolaByteOrder: true), processedIfdOffsets, makernoteOffset + 20);
            }
            else if (string.Equals("SIGMA\u0000\u0000\u0000", firstEightChars, StringComparison.Ordinal) ||
                     string.Equals("FOVEON\u0000\u0000", firstEightChars, StringComparison.Ordinal))
            {
                PushDirectory(new SigmaMakernoteDirectory());
                TiffReader.ProcessIfd(this, reader, processedIfdOffsets, makernoteOffset + 10);
            }
            else if (string.Equals("KDK", firstThreeChars, StringComparison.Ordinal))
            {
                var directory = new KodakMakernoteDirectory();
                Directories.Add(directory);
                ProcessKodakMakernote(directory, makernoteOffset, reader.WithByteOrder(isMotorolaByteOrder: firstSevenChars == "KDK INFO"));
            }
            else if ("CANON".Equals(cameraMake, StringComparison.OrdinalIgnoreCase))
            {
                PushDirectory(new CanonMakernoteDirectory());
                TiffReader.ProcessIfd(this, reader, processedIfdOffsets, makernoteOffset);
            }
            else if (cameraMake != null && cameraMake.StartsWith("CASIO", StringComparison.OrdinalIgnoreCase))
            {
                if (string.Equals("QVC\u0000\u0000\u0000", firstSixChars, StringComparison.Ordinal))
                {
                    PushDirectory(new CasioType2MakernoteDirectory());
                    TiffReader.ProcessIfd(this, reader, processedIfdOffsets, makernoteOffset + 6);
                }
                else
                {
                    PushDirectory(new CasioType1MakernoteDirectory());
                    TiffReader.ProcessIfd(this, reader, processedIfdOffsets, makernoteOffset);
                }
            }
            else if (string.Equals("FUJIFILM", firstEightChars, StringComparison.Ordinal) ||
                     string.Equals("FUJIFILM", cameraMake, StringComparison.OrdinalIgnoreCase))
            {
                // Note that this also applies to certain Leica cameras, such as the Digilux-4.3.
                // The 4 bytes after "FUJIFILM" in the makernote point to the start of the makernote
                // IFD, though the offset is relative to the start of the makernote, not the TIFF header
                var makernoteReader = reader.WithShiftedBaseOffset(makernoteOffset).WithByteOrder(isMotorolaByteOrder: false);
                var ifdStart        = makernoteReader.GetInt32(8);
                PushDirectory(new FujifilmMakernoteDirectory());
                TiffReader.ProcessIfd(this, makernoteReader, processedIfdOffsets, ifdStart);
            }
            else if (string.Equals("KYOCERA", firstSevenChars, StringComparison.Ordinal))
            {
                // http://www.ozhiker.com/electronics/pjmt/jpeg_info/kyocera_mn.html
                PushDirectory(new KyoceraMakernoteDirectory());
                TiffReader.ProcessIfd(this, reader, processedIfdOffsets, makernoteOffset + 22);
            }
            else if (string.Equals("LEICA", firstFiveChars, StringComparison.Ordinal))
            {
                // used by the X1/X2/X VARIO/T
                // (X1 starts with "LEICA\0\x01\0", Make is "LEICA CAMERA AG")
                // (X2 starts with "LEICA\0\x05\0", Make is "LEICA CAMERA AG")
                // (X VARIO starts with "LEICA\0\x04\0", Make is "LEICA CAMERA AG")
                // (T (Typ 701) starts with "LEICA\0\0x6", Make is "LEICA CAMERA AG")
                // (X (Typ 113) starts with "LEICA\0\0x7", Make is "LEICA CAMERA AG")

                if (string.Equals("LEICA\0\x1\0", firstEightChars, StringComparison.Ordinal) ||
                    string.Equals("LEICA\0\x4\0", firstEightChars, StringComparison.Ordinal) ||
                    string.Equals("LEICA\0\x5\0", firstEightChars, StringComparison.Ordinal) ||
                    string.Equals("LEICA\0\x6\0", firstEightChars, StringComparison.Ordinal) ||
                    string.Equals("LEICA\0\x7\0", firstEightChars, StringComparison.Ordinal))
                {
                    PushDirectory(new LeicaType5MakernoteDirectory());
                    TiffReader.ProcessIfd(this, reader.WithShiftedBaseOffset(makernoteOffset), processedIfdOffsets, 8);
                }
                else if (string.Equals("Leica Camera AG", cameraMake, StringComparison.Ordinal))
                {
                    PushDirectory(new LeicaMakernoteDirectory());
                    TiffReader.ProcessIfd(this, reader.WithByteOrder(isMotorolaByteOrder: false), processedIfdOffsets, makernoteOffset + 8);
                }
                else if (string.Equals("LEICA", cameraMake, StringComparison.Ordinal))
                {
                    // Some Leica cameras use Panasonic makernote tags
                    PushDirectory(new PanasonicMakernoteDirectory());
                    TiffReader.ProcessIfd(this, reader.WithByteOrder(isMotorolaByteOrder: false), processedIfdOffsets, makernoteOffset + 8);
                }
                else
                {
                    return(false);
                }
            }
            else if (string.Equals("Panasonic\u0000\u0000\u0000", firstTwelveChars, StringComparison.Ordinal))
            {
                // NON-Standard TIFF IFD Data using Panasonic Tags. There is no Next-IFD pointer after the IFD
                // Offsets are relative to the start of the TIFF header at the beginning of the EXIF segment
                // more information here: http://www.ozhiker.com/electronics/pjmt/jpeg_info/panasonic_mn.html
                PushDirectory(new PanasonicMakernoteDirectory());
                TiffReader.ProcessIfd(this, reader, processedIfdOffsets, makernoteOffset + 12);
            }
            else if (string.Equals("AOC\u0000", firstFourChars, StringComparison.Ordinal))
            {
                // NON-Standard TIFF IFD Data using Casio Type 2 Tags
                // IFD has no Next-IFD pointer at end of IFD, and
                // Offsets are relative to the start of the current IFD tag, not the TIFF header
                // Observed for:
                // - Pentax ist D
                PushDirectory(new CasioType2MakernoteDirectory());
                TiffReader.ProcessIfd(this, reader.WithShiftedBaseOffset(makernoteOffset), processedIfdOffsets, 6);
            }
            else if (cameraMake != null && (cameraMake.StartsWith("PENTAX", StringComparison.OrdinalIgnoreCase) || cameraMake.StartsWith("ASAHI", StringComparison.OrdinalIgnoreCase)))
            {
                // NON-Standard TIFF IFD Data using Pentax Tags
                // IFD has no Next-IFD pointer at end of IFD, and
                // Offsets are relative to the start of the current IFD tag, not the TIFF header
                // Observed for:
                // - PENTAX Optio 330
                // - PENTAX Optio 430
                PushDirectory(new PentaxMakernoteDirectory());
                TiffReader.ProcessIfd(this, reader.WithShiftedBaseOffset(makernoteOffset), processedIfdOffsets, 0);
            }
//          else if ("KC" == firstTwoChars || "MINOL" == firstFiveChars || "MLY" == firstThreeChars || "+M+M+M+M" == firstEightChars)
//          {
//              // This Konica data is not understood.  Header identified in accordance with information at this site:
//              // http://www.ozhiker.com/electronics/pjmt/jpeg_info/minolta_mn.html
//              // TODO add support for minolta/konica cameras
//              exifDirectory.addError("Unsupported Konica/Minolta data ignored.");
//          }
            else if (string.Equals("SANYO\x0\x1\x0", firstEightChars, StringComparison.Ordinal))
            {
                PushDirectory(new SanyoMakernoteDirectory());
                TiffReader.ProcessIfd(this, reader.WithShiftedBaseOffset(makernoteOffset), processedIfdOffsets, 8);
            }
            else if (cameraMake != null && cameraMake.StartsWith("RICOH", StringComparison.OrdinalIgnoreCase))
            {
                if (string.Equals(firstTwoChars, "Rv", StringComparison.Ordinal) ||
                    string.Equals(firstThreeChars, "Rev", StringComparison.Ordinal))
                {
                    // This is a textual format, where the makernote bytes look like:
                    //   Rv0103;Rg1C;Bg18;Ll0;Ld0;Aj0000;Bn0473800;Fp2E00:������������������������������
                    //   Rv0103;Rg1C;Bg18;Ll0;Ld0;Aj0000;Bn0473800;Fp2D05:������������������������������
                    //   Rv0207;Sf6C84;Rg76;Bg60;Gg42;Ll0;Ld0;Aj0004;Bn0B02900;Fp10B8;Md6700;Ln116900086D27;Sv263:0000000000000000000000��
                    // This format is currently unsupported
                    return(false);
                }
                if (firstFiveChars.Equals("RICOH", StringComparison.OrdinalIgnoreCase))
                {
                    PushDirectory(new RicohMakernoteDirectory());
                    // Always in Motorola byte order
                    TiffReader.ProcessIfd(this, reader.WithByteOrder(isMotorolaByteOrder: true).WithShiftedBaseOffset(makernoteOffset), processedIfdOffsets, 8);
                }
            }
            else if (string.Equals(firstTenChars, "Apple iOS\0", StringComparison.Ordinal))
            {
                PushDirectory(new AppleMakernoteDirectory());
                // Always in Motorola byte order
                TiffReader.ProcessIfd(this, reader.WithByteOrder(isMotorolaByteOrder: true).WithShiftedBaseOffset(makernoteOffset), processedIfdOffsets, 14);
            }
            else if (string.Equals("RECONYX", cameraMake, StringComparison.OrdinalIgnoreCase) ||
                     reader.GetUInt16(makernoteOffset) == ReconyxMakernoteDirectory.HyperFireMakernoteVersion)
            {
                var directory = new ReconyxMakernoteDirectory();
                Directories.Add(directory);
                ProcessReconyxMakernote(directory, makernoteOffset, reader);
            }
            else if (string.Equals("SAMSUNG", cameraMake, StringComparison.Ordinal))
            {
                // Only handles Type2 notes correctly. Others aren't implemented, and it's complex to determine which ones to use
                PushDirectory(new SamsungType2MakernoteDirectory());
                TiffReader.ProcessIfd(this, reader, processedIfdOffsets, makernoteOffset);
            }
            else
            {
                // The makernote is not comprehended by this library.
                // If you are reading this and believe a particular camera's image should be processed, get in touch.
                return(false);
            }

            return(true);
        }
コード例 #12
0
        public override bool CustomProcessTag(int tagOffset, ICollection <int> processedIfdOffsets, IndexedReader reader, int tagId, int byteCount)
        {
            // Some 0x0000 tags have a 0 byteCount. Determine whether it's bad.
            if (tagId == 0)
            {
                if (CurrentDirectory.ContainsTag(tagId))
                {
                    // Let it go through for now. Some directories handle it, some don't.
                    return(false);
                }

                // Skip over 0x0000 tags that don't have any associated bytes. No idea what it contains in this case, if anything.
                if (byteCount == 0)
                {
                    return(true);
                }
            }

            // Custom processing for the Makernote tag
            if (tagId == ExifDirectoryBase.TagMakernote && CurrentDirectory is ExifSubIfdDirectory)
            {
                return(ProcessMakernote(tagOffset, processedIfdOffsets, reader));
            }

            // Custom processing for embedded IPTC data
            if (tagId == ExifDirectoryBase.TagIptcNaa && CurrentDirectory is ExifIfd0Directory)
            {
                // NOTE Adobe sets type 4 for IPTC instead of 7
                if (reader.GetSByte(tagOffset) == 0x1c)
                {
                    var iptcBytes     = reader.GetBytes(tagOffset, byteCount);
                    var iptcDirectory = new IptcReader().Extract(new SequentialByteArrayReader(iptcBytes), iptcBytes.Length);
                    iptcDirectory.Parent = CurrentDirectory;
                    Directories.Add(iptcDirectory);
                    return(true);
                }
                return(false);
            }

            // Custom processing for embedded XMP data
            if (tagId == ExifDirectoryBase.TagApplicationNotes && CurrentDirectory is ExifIfd0Directory)
            {
                var xmpDirectory = new XmpReader().Extract(reader.GetNullTerminatedBytes(tagOffset, byteCount));
                xmpDirectory.Parent = CurrentDirectory;
                Directories.Add(xmpDirectory);
                return(true);
            }

            if (HandlePrintIM(CurrentDirectory, tagId))
            {
                var dirPrintIm = new PrintIMDirectory();
                dirPrintIm.Parent = CurrentDirectory;
                Directories.Add(dirPrintIm);
                ProcessPrintIM(dirPrintIm, tagOffset, reader, byteCount);
                return(true);
            }

            // Note: these also appear in TryEnterSubIfd because some are IFD pointers while others begin immediately
            // for the same directories
            if (CurrentDirectory is OlympusMakernoteDirectory)
            {
                switch (tagId)
                {
                case OlympusMakernoteDirectory.TagEquipment:
                    PushDirectory(new OlympusEquipmentMakernoteDirectory());
                    TiffReader.ProcessIfd(this, reader, processedIfdOffsets, tagOffset);
                    return(true);

                case OlympusMakernoteDirectory.TagCameraSettings:
                    PushDirectory(new OlympusCameraSettingsMakernoteDirectory());
                    TiffReader.ProcessIfd(this, reader, processedIfdOffsets, tagOffset);
                    return(true);

                case OlympusMakernoteDirectory.TagRawDevelopment:
                    PushDirectory(new OlympusRawDevelopmentMakernoteDirectory());
                    TiffReader.ProcessIfd(this, reader, processedIfdOffsets, tagOffset);
                    return(true);

                case OlympusMakernoteDirectory.TagRawDevelopment2:
                    PushDirectory(new OlympusRawDevelopment2MakernoteDirectory());
                    TiffReader.ProcessIfd(this, reader, processedIfdOffsets, tagOffset);
                    return(true);

                case OlympusMakernoteDirectory.TagImageProcessing:
                    PushDirectory(new OlympusImageProcessingMakernoteDirectory());
                    TiffReader.ProcessIfd(this, reader, processedIfdOffsets, tagOffset);
                    return(true);

                case OlympusMakernoteDirectory.TagFocusInfo:
                    PushDirectory(new OlympusFocusInfoMakernoteDirectory());
                    TiffReader.ProcessIfd(this, reader, processedIfdOffsets, tagOffset);
                    return(true);

                case OlympusMakernoteDirectory.TagRawInfo:
                    PushDirectory(new OlympusRawInfoMakernoteDirectory());
                    TiffReader.ProcessIfd(this, reader, processedIfdOffsets, tagOffset);
                    return(true);

                case OlympusMakernoteDirectory.TagMainInfo:
                    PushDirectory(new OlympusMakernoteDirectory());
                    TiffReader.ProcessIfd(this, reader, processedIfdOffsets, tagOffset);
                    return(true);
                }
            }

            if (CurrentDirectory is PanasonicRawIfd0Directory)
            {
                // these contain binary data with specific offsets, and can't be processed as regular ifd's.
                // The binary data is broken into 'fake' tags and there is a pattern.
                switch (tagId)
                {
                case PanasonicRawIfd0Directory.TagWbInfo:
                    var dirWbInfo = new PanasonicRawWbInfoDirectory();
                    dirWbInfo.Parent = CurrentDirectory;
                    Directories.Add(dirWbInfo);
                    ProcessBinary(dirWbInfo, tagOffset, reader, byteCount, false, 2);
                    return(true);

                case PanasonicRawIfd0Directory.TagWbInfo2:
                    var dirWbInfo2 = new PanasonicRawWbInfo2Directory();
                    dirWbInfo2.Parent = CurrentDirectory;
                    Directories.Add(dirWbInfo2);
                    ProcessBinary(dirWbInfo2, tagOffset, reader, byteCount, false, 3);
                    return(true);

                case PanasonicRawIfd0Directory.TagDistortionInfo:
                    var dirDistort = new PanasonicRawDistortionDirectory();
                    dirDistort.Parent = CurrentDirectory;
                    Directories.Add(dirDistort);
                    ProcessBinary(dirDistort, tagOffset, reader, byteCount);
                    return(true);
                }
            }

            // Panasonic RAW sometimes contains an embedded version of the data as a JPG file.
            if (tagId == PanasonicRawIfd0Directory.TagJpgFromRaw && CurrentDirectory is PanasonicRawIfd0Directory)
            {
                var jpegrawbytes = reader.GetBytes(tagOffset, byteCount);

                // Extract information from embedded image since it is metadata-rich
                var jpegmem       = new MemoryStream(jpegrawbytes);
                var jpegDirectory = Jpeg.JpegMetadataReader.ReadMetadata(jpegmem);
                foreach (var dir in jpegDirectory)
                {
                    dir.Parent = CurrentDirectory;
                    Directories.Add(dir);
                }
                return(true);
            }

            return(false);
        }
コード例 #13
0
 public IAssemblyCollection LoadDirectory(string path, SearchOption searchOption = SearchOption.AllDirectories)
 {
     Directories.Add(new Tuple <string, SearchOption>(path, searchOption));
     return(this);
 }
コード例 #14
0
ファイル: MockFileSystem.cs プロジェクト: OakRaven/ltaf
 public void CreateDirectory(string destinationPath)
 {
     Directories.Add(destinationPath);
 }
コード例 #15
0
 public InMemoryFileSystem()
 {
     Directories.Add(FilePath.Root, new HashSet <FilePath>());
 }
コード例 #16
0
 public void AddDirectory(string orig, string ext)
 {
     Directories.Add(new Tuple <string, string>(orig, ext));
 }
コード例 #17
0
 public void AddDirectory(string path) => Directories.Add(path);
コード例 #18
0
 void IFileSystem.CreateDirectory(string path)
 {
     Directories.Add(path);
 }
コード例 #19
0
        private void Read(FileStream stream)
        {
            byte[] sectorHeader = new byte[this.sectorSize];
            stream.Seek(this.rootSectorOffset, SeekOrigin.Begin);

            // read the first sector header, which contains subdirectories and file count
            stream.Read(sectorHeader, 0, sectorHeader.Length);

            uint nextSector = BitConverter.ToUInt32(sectorHeader, 0);

            fileCount = BitConverter.ToUInt32(sectorHeader, 252);

            // directory is allowed to have files + 1 subdirectories
            int         directories   = 0;
            uint        directory     = BitConverter.ToUInt32(sectorHeader, sizeof(uint));
            List <uint> directoryList = new List <uint>();

            while (directories < (fileCount + 1) && directory > 0)
            {
                directoryList.Add(directory);
                directories++;
                directory = BitConverter.ToUInt32(sectorHeader, (1 + directories) * sizeof(uint));
            }

            // directories done, on to files

            int totalSectors = 1;
            int arrayUsage   = 0;

            // maximum size we'll need
            byte[] sector = new byte[(this.sectorSize - 4) * 7];

            // copy over content from the first sector if it is bigger than just the header (happens in portal.dat, but not cell.dat)
            if (this.sectorSize > 256)
            {
                Array.Copy(sectorHeader, 256, sector, 0, this.sectorSize - 256);
                arrayUsage += (this.sectorSize - 256);
            }

            // separate buffer for the next sector location
            byte[] nextSectorBuffer = new byte[4];

            while (nextSector > 0 && totalSectors < 6)
            {
                // go to this sector
                stream.Seek(nextSector, SeekOrigin.Begin);

                // read the next sector pointer
                stream.Read(nextSectorBuffer, 0, sizeof(uint));

                // read this sector
                stream.Read(sector, arrayUsage, (this.sectorSize - 4));

                // maths for next loop
                arrayUsage += (this.sectorSize - 4);
                nextSector  = BitConverter.ToUInt32(nextSectorBuffer, 0);
                totalSectors++;
            }

            // sector has all the daters
            for (int i = 0; i < fileCount; i++)
            {
                Files.Add(DatFile.FromBuffer(sector, i * 6 * sizeof(uint), DatType));
            }

            // files done, go back and iterate directories
            foreach (uint directoryOffset in directoryList)
            {
                Directories.Add(new DatDirectory(directoryOffset, this.sectorSize, stream, DatType));
            }
        }
コード例 #20
0
        public bool ScanDirectory(string DirPrefix, ScanCallback Callback, BuildDBInfo UserData)
        {
            PInvoke.WIN32_FIND_DATA FindData;

            var DirIndice = (uint)Directories.Count - 1;

            var SearchString = DirPrefix + "*";

            var FindHandle = PInvoke.FindFirstFile(SearchString, out FindData);

            if (FindHandle == PInvoke.INVALID_HANDLE_VALUE)
            {
                return(false);
            }

            do
            {
                UInt64 FileSize = ((FindData.nFileSizeHigh << 32) | FindData.nFileSizeLow);

                FileInfo       Info   = new FileInfo(FindData.cFileName, DirIndice, FileSize, FindData.dwFileAttributes);
                SafeFileHandle Handle = null;

                // DonLL't ever include '.L' and '..'
                if (Info.Name == "." || Info.Name == "..")
                {
                    continue;
                }

                //Info.FullName = DirPrefix + Info.Name;

                Info.Clusters = 0;
                if (GetClusterInfo(Info, ref Handle))
                {
                    UInt64 TotalClusters = Info.Fragments.Aggregate <Extent, ulong>(0, (current, ext) => current + ext.Length);

                    Info.Clusters = TotalClusters;
                }
                else
                {
                    Info.Attributes.Unmovable = true;
                    Info.Attributes.Process   = false;
                }

                if (Info.Attributes.Process)
                {
                    Info.Attributes.Process = ShouldProcess(Info.Attributes);
                }

                // Run the user-defined callback function
                var CallbackResult = Callback(ref Info, ref Handle, ref UserData);

                if (!Handle.IsInvalid && !Handle.IsClosed)
                {
                    Handle.Close();
                }

                if (!CallbackResult)
                {
                    break;
                }

                // If directory, perform recursion
                if (Info.Attributes.Directory)
                {
                    var Dir = GetDBDir(Info.DirIndice);
                    Dir += Info.Name;
                    Dir += "\\";

                    Directories.Add(Dir);
                    ScanDirectory(Dir, Callback, UserData);
                }
            } while (PInvoke.FindNextFile(FindHandle, out FindData));

            PInvoke.FindClose(FindHandle);
            return(false);
        }
コード例 #21
0
        /// <summary>
        /// Add directory item clicked
        /// </summary>
        /// <param name="sender">Menu instance</param>
        /// <param name="e">Argumetns</param>
        private void AddDirectoryItemClick(object sender, Telerik.Windows.RadRoutedEventArgs e)
        {
            var directoryType = ((sender as RadMenuItem).Tag as DirectoryType);

            var container = directoryTreeView.SelectedContainer;

            var directory = new Directory
            {
                DirectoryTypeId = directoryType.Id,
                Name            = localizationService.Translate("fs_new_directory_name")
            };

            // Save child directory list
            ObservableCollection <DirectoryViewModel> childrenDirectory = null;

            var directoryViewModel = new DirectoryViewModel(directory, this)
            {
                Parent = SelectedDirectory as IViewModelBase ?? this
            };

            if (SelectedDirectory == null)
            {
                Directories.Add(directoryViewModel);
                childrenDirectory = Directories;
            }
            else
            {
                directory.Parent = SelectedDirectory.Model;
                SelectedDirectory.Directories.Add(directoryViewModel);

                childrenDirectory = SelectedDirectory.Directories;
            }
            if (!(SelectedDirectory == null || SelectedDirectory.Model == null))
            {
                directoryViewModel.Model.WorkflowId = SelectedDirectory.Model.WorkflowId;
            }

            SelectedDirectory = directoryViewModel;
            RawDirectories.Add(directoryViewModel);

            // Check if directory is already existing
            var currentName = directoryViewModel.Name;
            int nameCounter = 1;

            while (childrenDirectory.Any(x => x.Name?.ToLower() == currentName.ToLower() && x != directoryViewModel))
            {
                currentName = $"{directoryViewModel.Name} {nameCounter}";
                nameCounter++;
            }

            directoryViewModel.Name = currentName;

            // Expand parent
            if (container?.IsExpanded != null)
            {
                container.IsExpanded = true;
            }

            IsDirty = true;

            RefreshPath();
        }
コード例 #22
0
 void IFileSystem.CreateDirectory(string path)
 {
     Directories.Add(TrimSlash(path));
 }
コード例 #23
0
 public void AddDirectoryManually(string path, ScsEntry entry)
 {
     Directories.Add(entry.GetHash(), new ScsDirectory(_rfs, path));
 }
コード例 #24
0
 public void AddDirectory(TreeDirectoryData directory)
 {
     Directories.Add(directory);
 }
コード例 #25
0
        protected override void Execute()
        {
            List <DirectoryInfo> ToSearch = new List <DirectoryInfo>();

            // Add directory to queue
            try
            {
                ToSearch.Add(new DirectoryInfo(_Directory));
            }
            catch (DirectoryNotFoundException dnf)
            {
                RaiseLogMessage("HANDLED DIRECTORYNOTFOUNDEXCEPTION while trying to read directory '" + _Directory + "': " + dnf.Message);
            }
            catch (Exception e)
            {
                RaiseLogError("UNHANDLED EXCEPTION while trying to read directory '" + _Directory + "': " + e.Message);
            }

            while (ToSearch.Count > 0)
            {
                DirectoryInfo DI = ToSearch[0];
                ToSearch.RemoveAt(0);
                Directories.Add(Regex.Replace(DI.FullName, _ReplaceInKey, "", RegexOptions.IgnoreCase), DI.FullName);

                RaiseDirectoryChanged(DI.FullName);

                if (_WantFiles)
                {
                    try
                    {
                        foreach (FileData FD in FastDirectoryEnumerator.EnumerateFiles(DI.FullName, "*.*", _Recurse ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly))
                        {
                            Files.Add(Regex.Replace(FD.Path, _ReplaceInKey, "", RegexOptions.IgnoreCase), FD);
                        }
                    }
                    catch (DirectoryNotFoundException dnf)
                    {
                        RaiseLogMessage("HANDLED DIRECTORYNOTFOUNDEXCEPTION while trying to read files in directory '" + DI.FullName + "': " + dnf.Message);
                    }
                    catch (Exception e)
                    {
                        RaiseLogError("UNHANDLED EXCEPTION while trying to read files in directory '" + DI.FullName + "': " + e.Message);
                    }
                }

                if (_Recurse)
                {
                    try
                    {
                        ToSearch.AddRange(DI.GetDirectories());
                    }
                    catch (DirectoryNotFoundException dnf)
                    {
                        RaiseLogMessage("HANDLED DIRECTORYNOTFOUNDEXCEPTION while trying to read subdirectories in directory '" + DI.FullName + "': " + dnf.Message);
                    }
                    catch (Exception e)
                    {
                        RaiseLogError("UNHANDLED EXCEPTION while trying to read subdirectories in directory '" + DI.FullName + "': " + e.Message);
                    }
                }
            }
        }
コード例 #26
0
 public void AddDirectory(DirectoryEntry entry)
 {
     entry._parent = this;
     Directories.Add(entry);
 }
コード例 #27
0
 public void CreateDirectory(string path)
 {
     Directories.Add(path);
 }
コード例 #28
0
ファイル: Directory.cs プロジェクト: AstRyou/All
 public void addSubDir()
 {
     Directories.Add(new Directory(Directories));
     NotifyPropertyChanged("addsub");
 }
コード例 #29
0
ファイル: Settings.cs プロジェクト: aradzu10/ImageService
 public void AddDirectories(string dir)
 {
     Directories.Add(dir);
 }
コード例 #30
0
        // Parses the arguments passed to SauronEye, using Mono.Options
        public void ParseArgumentsOptions(string[] args)
        {
            var    shouldShowHelp   = false;
            string currentParameter = "";
            var    options          = new OptionSet()
            {
                { "sh|shares=", "Shares to search", v => {
                      Shares.Add(v);
                      currentParameter = "sh";
                  } },
                { "d|directories=", "Directories to search", v => {
                      Directories.Add(v);
                      currentParameter = "d";
                  } },
                { "f|filetypes=", "Filetypes to search for/in", v => {
                      FileTypes.Add(v);
                      currentParameter = "f";
                  } },
                { "k|keywords=", "Keywords to search for", v => {
                      Keywords.Add(v);
                      currentParameter = "k";
                  } },
                { "c|contents", "Search file contents", c => SearchContents = c != null },
                { "m|maxfilesize=", "Max file size to search contents in, in kilobytes", m => { CheckInteger(m); } },
                { "b|beforedate=", "Filter files last modified before this date, \n format: yyyy-MM-dd", b => { CheckDate(b, "before"); } },
                { "a|afterdate=", "Filter files last modified after this date, \n format: yyyy-MM-dd", a => { CheckDate(a, "after"); } },
                { "s|systemdirs", "Search in filesystem directories %APPDATA% and %WINDOWS%", s => SystemDirs = s != null },
                { "v|vbamacrocheck", "Check if 2003 Office files (*.doc and *.xls) contain a VBA macro", s => CheckForMacro = s != null },
                { "h|help", "Show help", h => shouldShowHelp = h != null },
                { "<>", v => {
                      switch (currentParameter)
                      {
                      case "d":
                          Directories.Add(v);
                          break;

                      case "f":
                          FileTypes.Add(v);
                          break;

                      case "k":
                          Keywords.Add(v);
                          break;

                      case "":
                          break;
                      }
                  } }
            };

            List <string> extra;

            try {
                extra = options.Parse(args);
            } catch (OptionException e) {
                Console.Write("SauronEye.exe: ");
                Console.WriteLine(e.Message);
                Console.WriteLine("Try 'SauronEye.exe --help' for more information.");
                System.Environment.Exit(1);
            }

            if (shouldShowHelp)
            {
                ShowHelp(options);
                System.Environment.Exit(1);
            }
            CheckArgs();
            Shares        = Shares.Where(s => !isNullOrWhiteSpace(s)).Distinct().ToList();
            Directories   = Directories.Where(s => !isNullOrWhiteSpace(s)).Distinct().ToList();
            FileTypes     = FileTypes.Where(s => !isNullOrWhiteSpace(s)).Distinct().ToList();
            Keywords      = Keywords.Where(s => !isNullOrWhiteSpace(s)).Distinct().ToList();
            regexSearcher = new RegexSearch(Keywords);
            return;
        }