public FileData(string path,IFileType fileType) { this.FileType = fileType; var fileInfo = new FileInfo(path); this.CreateDate = fileInfo.CreationTime; this.Path=new List<string> {fileInfo.FullName}; this.Checksum = CheckSum.Calculate(path); if (fileType.FileContentExtractor!=null) { this.Content = fileType.FileContentExtractor.Extract(path); } }
public FileExtensionProvider(string path) { infos = new InfoCollection(); var fileTypes = new IFileType[] { //new MpegAudioFileType(), //new MpegVideoFileType(), //new WavFileType(), new SrtFileType(), new AssSsaFileType(), new IdxFileType(), new SamiFileType(), new C7zFileType(), new ZipFileType(), new RarFileType(), new RaFileType(), new FlacFileType(), new LrcFileType(), new AviFileType(), new SubFileType(), new TmpFileType(), new PJSFileType(), new JSFileType(), new RTFileType(), new SMILFileType(), new TTSFileType(), new XSSFileType(), new ZeroGFileType(), new SUPFileType(), new FanSubberFileType(), new Sasami2kFileType() }; using(Stream stream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read)) { int b; bool needMoreBytes = true; while(needMoreBytes) { b = stream.ReadByte(); if(b == -1 || stream.Position > 1 << 30) return; needMoreBytes = false; foreach(var fileType in fileTypes.Where(f => f.IsCandidate)) { fileType.CheckMagicByte((byte)b); needMoreBytes |= fileType.NeedsMoreMagicBytes; } } foreach(var fileType in fileTypes.Where(f => f.IsCandidate)) { stream.Position = 0; fileType.ElaborateCheck(stream); } } var exts = fileTypes.Where(f => f.IsCandidate); if(exts.Count() != 1) { if(exts.Any(ft => ft.PossibleExtensions[0].Equals("zip"))) exts = new List<IFileType>(new IFileType[] { new ZipFileType() }); if(exts.Any(ft => ft.PossibleExtensions[0].Equals("7z"))) exts = new List<IFileType>(new IFileType[] { new C7zFileType() }); if(exts.Any(ft => ft.PossibleExtensions[0].Equals("rar"))) exts = new List<IFileType>(new IFileType[] { new RarFileType() }); } string extsStr; if(fileTypes.Any(f => f.IsCandidate)) { extsStr = exts.Aggregate<IFileType, IEnumerable<string>>(new string[0], (acc, f) => acc.Concat(f.PossibleExtensions)).Aggregate((acc, str) => acc + " " + str); } else { extsStr = null; } Add(EntryKey.Extension, extsStr, null); if(exts.Count() == 1) exts.Single().AddInfo(Add); }
/// <summary> /// 构造函数 /// </summary> public FileTypeController() { _ctrl = GetCtrl<IFileType>("FileType"); }
public Viewmodel(IFileType fileType) { FileType = fileType; Configure(); FileType.Initialize(); }
public Modelconfig(IFileType fileType) { FileType = fileType; Configure(); FileType.Initialize(); }
/// <summary> /// @param IFileType /// @return /// </summary> public IFileType SetFileType(IFileType type) { this.file = type; return(file); }
/// <summary> /// Initializes a new instance of the NewFileEventArgs class with /// the IFileType of the file that should be created. /// </summary> /// <param name="fileType">See <see cref="FileType" /></param> public NewFileEventArgs(IFileType fileType) { FileType = fileType; }
public static bool IsValidExtension(this IFileType type, string extension) { return(type.Extensions.Contains(extension, StringComparer.OrdinalIgnoreCase)); }
public MatchScore(IFileType fileType, int score) { this.Type = fileType; this.Score = score; }
public Serviceapp(IFileType fileType) { FileType = fileType; Configure(); FileType.Initialize(); }
public StreamProgressInfo(IFileType file) { this.fileType = file; }