protected IEnumerable <FileImportInfo> ScanPhotoDirectory(bool recurseSubdirectories, bool mergeRawAndJpeg, Uri uri) { var enumerator = (new RecursiveFileEnumerator(uri, fileSystem) { Recurse = recurseSubdirectories, CatchErrors = true, IgnoreSymlinks = true }).GetEnumerator(); Uri file = null; while (true) { if (file == null) { file = NextImageFileOrNull(enumerator); if (file == null) { break; } } // peek the next file to see if we have a RAW+JPEG combination // skip any non-image files var nextFile = NextImageFileOrNull(enumerator); Uri original; Uri version = null; if (mergeRawAndJpeg && nextFile != null && factory.IsJpegRawPair(file, nextFile)) { // RAW+JPEG: import as one photo with versions original = factory.IsRaw(file.GetExtension()) ? file : nextFile; version = factory.IsRaw(file.GetExtension()) ? nextFile : file; // current and next files consumed in this iteration, // prepare to get next file on next iteration file = null; } else { // import current file as single photo original = file; // forward peeked file to next iteration of loop file = nextFile; } FileImportInfo info; if (version == null) { info = new FileImportInfo(original, Strings.Original); } else { info = new FileImportInfo(original, Strings.OriginalRaw); info.AddVersion(version, Strings.OriginalJpeg); } yield return(info); } }
protected void ScanPhotoDirectory(ImportController controller, SafeUri uri, PhotoList photo_list) { var enumerator = new RecursiveFileEnumerator(uri) { Recurse = controller.RecurseSubdirectories, CatchErrors = true, IgnoreSymlinks = true }; foreach (var file in enumerator) { if (ImageFile.HasLoader(new SafeUri(file.Uri.ToString(), true))) { var info = new FileImportInfo(new SafeUri(file.Uri.ToString(), true)); ThreadAssist.ProxyToMain(() => photo_list.Add(info)); } if (!run_photoscanner) { return; } } }
protected void ScanPhotoDirectory (bool recurseSubdirectories, bool mergeRawAndJpeg, SafeUri uri) { var enumerator = (new RecursiveFileEnumerator (uri) { Recurse = recurseSubdirectories, CatchErrors = true, IgnoreSymlinks = true }).GetEnumerator (); SafeUri file = null; while (true) { if (file == null) { file = NextImageFileOrNull(enumerator); if (file == null) break; } // peek the next file to see if we have a RAW+JPEG combination // skip any non-image files SafeUri nextFile = NextImageFileOrNull(enumerator); SafeUri original; SafeUri version = null; if (mergeRawAndJpeg && nextFile != null && IsJpegRawPair (file, nextFile)) { // RAW+JPEG: import as one photo with versions original = ImageFile.IsRaw (file) ? file : nextFile; version = ImageFile.IsRaw (file) ? nextFile : file; // current and next files consumed in this iteration, // prepare to get next file on next iteration file = null; } else { // import current file as single photo original = file; // forward peeked file to next iteration of loop file = nextFile; } FileImportInfo info; if (version == null) { info = new FileImportInfo (original, Catalog.GetString ("Original")); } else { info = new FileImportInfo (original, Catalog.GetString ("Original RAW")); info.AddVersion (version, Catalog.GetString ("Original JPEG")); } ThreadAssist.ProxyToMain (() => { if (PhotoFoundEvent != null) { PhotoFoundEvent.Invoke (this, new PhotoFoundEventArgs { FileImportInfo = info }); } }); if (!run_photoscanner) return; } }
protected void ScanPhotoDirectory(bool recurseSubdirectories, bool mergeRawAndJpeg, SafeUri uri) { var enumerator = (new RecursiveFileEnumerator(uri) { Recurse = recurseSubdirectories, CatchErrors = true, IgnoreSymlinks = true }).GetEnumerator(); SafeUri file = null; while (true) { if (file == null) { file = NextImageFileOrNull(enumerator); if (file == null) { break; } } // peek the next file to see if we have a RAW+JPEG combination // skip any non-image files SafeUri nextFile = NextImageFileOrNull(enumerator); SafeUri original; SafeUri version = null; if (mergeRawAndJpeg && nextFile != null && IsJpegRawPair(file, nextFile)) { // RAW+JPEG: import as one photo with versions original = ImageFile.IsRaw(file) ? file : nextFile; version = ImageFile.IsRaw(file) ? nextFile : file; // current and next files consumed in this iteration, // prepare to get next file on next iteration file = null; } else { // import current file as single photo original = file; // forward peeked file to next iteration of loop file = nextFile; } FileImportInfo info; if (version == null) { info = new FileImportInfo(original, Catalog.GetString("Original")); } else { info = new FileImportInfo(original, Catalog.GetString("Original RAW")); info.AddVersion(version, Catalog.GetString("Original JPEG")); } ThreadAssist.ProxyToMain(() => { if (PhotoFoundEvent != null) { PhotoFoundEvent.Invoke(this, new PhotoFoundEventArgs { FileImportInfo = info }); } }); if (!run_photoscanner) { return; } } }
protected void ScanPhotoDirectory(ImportController controller, SafeUri uri, PhotoList photo_list) { var enumerator = new RecursiveFileEnumerator (uri) { Recurse = controller.RecurseSubdirectories, CatchErrors = true, IgnoreSymlinks = true }; foreach (var file in enumerator) { if (ImageFile.HasLoader (new SafeUri (file.Uri.ToString(), true))) { var info = new FileImportInfo (new SafeUri (file.Uri.ToString (), true)); ThreadAssist.ProxyToMain (() => photo_list.Add (info)); } if (!run_photoscanner) return; } }