/// <summary> /// Gets info for the selected item (SelectedItemPath). /// </summary> /// <param name="infoType">Type of info to return.</param> /// <param name="singleLine">if set to <c>true</c>, put the info in a single line.</param> /// <returns> /// Specified info for the selected file. /// </returns> protected override string GetInfo(RequestedInfoType infoType, bool singleLine) { // Switch on the tip of info we need to provide. switch (infoType) { case RequestedInfoType.InfoTip: // Format the formatted info tip. return(string.Format(singleLine ? "{0} - {1} Items" : "{0}" + Environment.NewLine + "Contains {1} Items", Path.GetFileName(SelectedItemPath), Directory.GetFiles(SelectedItemPath).Length)); case RequestedInfoType.Name: // Return the name of the folder. return(string.Format("Folder '{0}'", Path.GetFileName(SelectedItemPath))); default: // We won't be asked for anything else, like shortcut paths, for folders, so we // can return an empty string in the default case. return(string.Empty); } }
/// <summary> /// Gets info for the selected item (SelectedItemPath). /// </summary> /// <param name="infoType">Type of info to return.</param> /// <param name="singleLine">if set to <c>true</c>, put the info in a single line.</param> /// <returns> /// Specified info for the selected file. /// </returns> protected override string GetInfo(RequestedInfoType infoType, bool singleLine) { // Switch on the tip of info we need to provide. switch (infoType) { case RequestedInfoType.InfoTip: // Format the formatted info tip. return string.Format(singleLine ? "{0} - {1} Items" : "{0}" + Environment.NewLine + "Contains {1} Items", Path.GetFileName(SelectedItemPath), Directory.GetFiles(SelectedItemPath).Length); case RequestedInfoType.Name: // Return the name of the folder. return string.Format("Folder '{0}'", Path.GetFileName(SelectedItemPath)); default: // We won't be asked for anything else, like shortcut paths, for folders, so we // can return an empty string in the default case. return string.Empty; } }
protected override string GetInfo(RequestedInfoType infoType, bool singleLine) { switch (infoType) { case RequestedInfoType.InfoTip: return(FindTip()); default: return(string.Empty); } }
protected override string GetInfo(RequestedInfoType infoType, bool singleLine) { switch (infoType) { case RequestedInfoType.InfoTip: try { var fi = new FileInfo(SelectedItemPath); if (fi.Length > 2000000) { return(CannotParse); } Torrent t; using (var ms = new MemoryStream()) using (var fs = fi.OpenRead()) { fs.CopyTo(ms); if (!Torrent.TryParse(ms.ToArray(), out t)) { return(ParseFail); } } return(string.Format(Template, t.Name, t.Files.Length, string.Join("\n", t.Files. OrderByDescending(c => c.Length). Take(10). Select(c => $"{c.Name} <{(c.Length < 1000000 ? c.Length + "Bytes" : c.Length / 1000000f + "MB")}>")), t.CreationDate.ToString("F"))); } catch (Exception ex) { return($"{ParseFail}:\n{ex.Message}"); } case RequestedInfoType.Name: return($"{FolderStr}{Path.GetFileName(SelectedItemPath)}'"); default: return(string.Empty); } }
protected override string GetInfo(RequestedInfoType infoType, bool singleLine) { switch (infoType) { case RequestedInfoType.InfoTip: if (File.Exists(Path.Combine(SelectedItemPath, @"sce_sys\param.sfo")) && File.Exists(Path.Combine(SelectedItemPath, @"sce_sys\icon0.png"))) { try { byte[] sfodata = File.ReadAllBytes(Path.Combine(SelectedItemPath, @"sce_sys\param.sfo")); SFOReader sfoReader = new SFOReader(sfodata); string result = string.Format("PSVita Game Folder\nTITLE:{0}\nTITLE_ID:{1}\nCONTENT_ID:{2}\nPSP2_DISP_VER:{3}\nVERSION:{4}", sfoReader.TITLE, sfoReader.TITLE_ID, sfoReader.CONTENT_ID, sfoReader.PSP2_DISP_VER, sfoReader.VERSION); sfodata = null; GC.Collect(); return(result); } catch { Logger.Error("SFO Reading Error", string.Format("Error occured in reading {0}", Path.Combine(SelectedItemPath, @"sce_sys\param.sfo"))); return(string.Empty); } } DirectoryInfo info = new DirectoryInfo(SelectedItemPath); return(string.Format("{0}\n{1}", Path.GetFileName(SelectedItemPath), Directory.GetCreationTime(SelectedItemPath))); case RequestedInfoType.Name: return(string.Format("Folder '{0}'", Path.GetFileName(SelectedItemPath))); default: return(string.Empty); } }
/// <summary> /// Gets info for the selected item (SelectedItemPath). /// </summary> /// <param name="infoType">Type of info to return.</param> /// <param name="singleLine">if set to <c>true</c>, put the info in a single line.</param> /// <returns> /// Specified info for the selected file. /// </returns> protected abstract string GetInfo(RequestedInfoType infoType, bool singleLine);