/// <summary> /// 指定されたファイルについて検査 /// </summary> /// <param name="files"></param> /// <param name="relatedFiles"></param> /// <param name="prospectedTags"></param> /// <returns></returns> public async Task <bool> CheckFolderUpdateAsync( string[] files, PropertiesLevel level, IReadOnlyDictionary <string, Record> relatedFiles, ConcurrentDictionary <string, ConcurrentBag <TagManager> > prospectedTags) { var folder = this.Config.GetFolderContainer(this.Path); var count = await folder.EnumerateFilesAsync (files, default(CancellationToken), false); var options = new LoadingOptions() { LightMode = true, ContainsChildren = false, Level = level,// PropertiesLevel.Basic, }; this.FileEnumerated?.Invoke(0); this.FileLoaded?.Invoke(0); await this.DoForAllFilesAsync(folder, options, relatedFiles, prospectedTags); var detected = new HashSet <string>(this.DetectedFiles); this.RemovedFiles = relatedFiles .AsParallel() .Where(x => !detected.Contains(x.Key)) .ToDictionary(x => x.Key, x => x.Value); return(true); }
/// <summary> /// フォルダ内のファイルを列挙 /// </summary> /// <param name="information"></param> /// <param name="relatedFiles"></param> /// <param name="completely"></param> /// <param name="level"></param> /// <param name="prospectedTags"></param> /// <returns></returns> public async Task <bool> ListupFilesAsync(FolderInformation information, IReadOnlyDictionary <string, Record> relatedFiles, bool completely, PropertiesLevel level, ConcurrentDictionary <string, ConcurrentBag <TagManager> > prospectedTags) { this.Path = PathUtility.WithPostSeparator(information.Path); this.TopPath = this.Path; var exists = await this.Config.IsFolderExistsAsync(information); //フォルダ取得に失敗 if (!exists) { this.RemovedFiles = relatedFiles.ToDictionary(x => x.Key, x => x.Value); information.RefreshEnable = false; return(false); } //ファイル検索オプション var options = new LoadingOptions() { LightMode = (information.Mode == FolderCheckMode.Light) ? true : (information.Mode == FolderCheckMode.Detail) ? false : !completely, ContainsChildren = !information.IsTopDirectoryOnly, Level = level,//PropertiesLevel.Basic, }; this.ChildFolderLoaded?.Invoke(this.Path); this.FileEnumerated?.Invoke(0); this.FileLoaded?.Invoke(0); var folder = this.Config.GetFolderContainer(this.Path); var count = await folder.EnumerateFilesAsync (x => this.FileEnumerated?.Invoke(x), options.ContainsChildren, default(CancellationToken), false); await this.DoForAllFilesAsync(folder, options, relatedFiles, prospectedTags); this.FileLoaded?.Invoke((int)count); //旧ライブラリに存在するのに検査して見つからなかったファイルを //削除された(可能性のある)ファイルとしてリストアップしておく var detected = new HashSet <string>(this.DetectedFiles); this.RemovedFiles = relatedFiles .AsParallel() .Where(x => !detected.Contains(x.Key)) .ToDictionary(x => x.Key, x => x.Value); information.RefreshEnable = false; return(true); }
public ImageFileInformation GetImage(string path, PropertiesLevel level) { return(this.GetAllFiles().FirstOrDefault(x => x.Path.Equals(path))); }
/// <summary> /// 画像ファイルの情報を取得 /// </summary> /// <param name="fullPath"></param> /// <param name="level"></param> /// <returns></returns> public ImageFileInformation GetImage(string fullPath, PropertiesLevel level) { ImageFileInformation image = null; var hasDecoration = true; try { var name = System.IO.Path.GetFileName(fullPath); var isUnknownType = false; var width = 0; var height = 0; var length = 0L; //画像ファイルのヘッダからサイズを抽出 if (level >= PropertiesLevel.Size) { var graphicInfo = new GraphicInformation(fullPath); width = graphicInfo.GraphicSize.Width; height = graphicInfo.GraphicSize.Height; length = graphicInfo.FileSize; isUnknownType = graphicInfo.Type == GraphicFileType.Unknown; //タグ・評価を付加できないファイルの場合は情報読み取りをスキップ if (graphicInfo.Type != GraphicFileType.Jpeg && graphicInfo.Type != GraphicFileType.Tiff && graphicInfo.Type != GraphicFileType.Psd && graphicInfo.Type != GraphicFileType.Unknown) { hasDecoration = false; } } var creationTime = defaultDateTime; var lastWriteTime = defaultDateTime; //日付情報 if (level >= PropertiesLevel.Basic) { try { var file = new System.IO.FileInfo(fullPath); creationTime = ImageFileUtility.ConvertDateTime(file.CreationTime); lastWriteTime = ImageFileUtility.ConvertDateTime(file.LastWriteTime); } catch { //No operation } } image = new ImageFileInformation() { DateCreated = creationTime, DateModified = lastWriteTime, Name = name, Path = fullPath, Height = height, Width = width, Size = length, Rating = 0, Keywords = null, IsNotFound = isUnknownType, }; } catch { return(null); } if (image == null) { return(null); } var rating = 0; HashSet <string> tags = null; //画像の評価・キーワード(時間かかる) if (level >= PropertiesLevel.Shell && hasDecoration) { try { var fileAccesser = this.GetFile(fullPath, image.Name); var kw = fileAccesser.GetDetailsOf(18); if (kw != null) { tags = new HashSet <string>(kw .Split(';') .Select(x => x.Trim()) .Where(x => x != null && x.Length > 0) .Distinct()); } rating = 0; var rateText = fileAccesser.GetDetailsOf(19); var rateArray = rateText? .Select(x => x - '0') .Where(x => x > 0 && x <= 5) .ToArray(); if (rateArray != null && rateArray.Length == 1) { rating = RateConvertingHelper.Reverse(rateArray[0]); } } catch { return(null); } } image.Rating = rating; image.Keywords = tags; return(image); }
/// <summary> /// 指定パスの画像ファイル情報を取得 /// </summary> /// <param name="path"></param> /// <param name="level"></param> /// <returns></returns> public ImageFileInformation GetImage(string path, PropertiesLevel level) { return(this.accesser.GetImage(path, level)); }