No cache version.

Caching disabled. Default setting for this page:enabled (code LNG204)
If the display is too slow, you can disable the user mode to view the cached version.

MediaParser.cs

Description du code

MediaParser.cs est un fichier du projet BrolExplorer.
Ce fichier est situé dans /var/www/bin/sniplets/bibliobrol/brolexplorer/.

Projet BrolExplorer :

Explorateur de media en CSharp.

Code source ou contenu du fichier

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.ComponentModel;
  5. using System.IO;
  6. using be.gaudry.model.file;
  7.  
  8. namespace be.gaudry.explorer.model
  9. {
  10. public class MediaParser : AbstractFileParser
  11. {
  12. #region constructors and declarations
  13.  
  14. private List<String> extensions;
  15. private long minimumSize;
  16. private String searchText;
  17. private bool findDVD, findAllExtensions;
  18.  
  19. public MediaParser():base()
  20. {
  21. extensions = new List<String>();
  22. minimumSize = 0L;
  23. findDVD = false;
  24. findAllExtensions = false;
  25. }
  26. #endregion
  27.  
  28. #region properties
  29. public String SearchText
  30. {
  31. get { return this.searchText; }
  32. set
  33. {
  34. //ToUpper() not allowed on null objects
  35. this.searchText = (value != null) ? value.ToUpper() : null;
  36. }
  37. }
  38. public long MinimumSize
  39. {
  40. get { return minimumSize; }
  41. set { minimumSize = value; }
  42. }
  43. public bool FindDVD
  44. {
  45. get { return findDVD; }
  46. set { findDVD = value; }
  47. }
  48. public bool FindAllExtensions
  49. {
  50. get { return findAllExtensions; }
  51. set { findAllExtensions = value; }
  52. }
  53. public List<String> Extensions
  54. {
  55. get { return this.extensions; }
  56. set
  57. {
  58. this.extensions.Clear();
  59. for (int i = 0; i < value.Count; i++)
  60. {
  61. if (!value[i].StartsWith("."))
  62. extensions.Add(String.Format(".{0}", value[i]).ToUpper());
  63. else
  64. extensions.Add(value[i].ToUpper());
  65. }
  66. }
  67. }
  68. #endregion
  69.  
  70. #region public methods
  71. public void addExtension(String extension)
  72. {
  73. if (!extension.StartsWith("."))
  74. extensions.Add(String.Format(".{0}", extension).ToUpper());
  75. else
  76. extensions.Add(extension.ToUpper());
  77. }
  78. #endregion
  79.  
  80. #region method to implement
  81. /// <summary>
  82. /// Do something on each file
  83. /// </summary>
  84. /// <param name="bgw">BackgroundWorker to perform cancel if needed, and report progress</param>
  85. /// <param name="e">DoWorkEventArgs to perform cancel if needed, and report progress</param>
  86. /// <param name="fi">FileInfo to check</param>
  87. /// <param name="percent">(int) Progress percentage</param>
  88. /// <param name="subDirDeep">Deep of the directory in comparison with start directory</param>
  89. /// <returns>
  90. /// true if we must stop the parsing of current directory (ie. if we have a vob file, we don't check the other files in this directory)
  91. /// false otherwise
  92. ///</returns>
  93. protected override bool performOnFile(BackgroundWorker bgw, DoWorkEventArgs e, FileInfo fi, int progressPercent, int subDirDeep)
  94. {
  95. if (findDVD)
  96. {
  97. if (".VOB".Equals(fi.Extension.ToUpper()))
  98. {
  99. string dvdName = "VIDEO_TS".Equals(fi.Directory.Name.ToUpper()) ? fi.Directory.Parent.Name : fi.Directory.Name;
  100. if (!testName(dvdName))//search by part of name
  101. {
  102. bgw.ReportProgress(progressPercent, null);
  103. return true;
  104. }
  105. long dirSize = FileHelper.getDirectoryLength(bgw, e, fi.Directory, IncludeSubFolders);
  106. if (
  107. minimumSize > 0
  108. && minimumSize > dirSize
  109. )
  110. {
  111. bgw.ReportProgress(progressPercent, null);
  112. return true;
  113. }
  114. bgw.ReportProgress(progressPercent, new object[]
  115. {
  116. fi.FullName,
  117. "DVD",
  118. dvdName,
  119. fi.Directory.FullName,
  120. dirSize
  121. });
  122. return true;
  123. }
  124. }
  125. if (!testName(fi.Name))//search by part of name
  126. {
  127. bgw.ReportProgress(progressPercent, null);
  128. return false;
  129. }
  130. if (findAllExtensions || extensions.Contains(fi.Extension.ToUpper()))
  131. {
  132. long fileLength;
  133. try { fileLength = fi.Length; }
  134. catch (Exception) { fileLength = 0L; }
  135. if (minimumSize == 0L || fileLength > minimumSize)
  136. {
  137. bgw.ReportProgress(progressPercent, new object[]
  138. {
  139. fi.FullName,
  140. fi.Extension.ToUpper(),
  141. fi.Name,
  142. fi.Directory.FullName ,
  143. fi.Length
  144. });
  145. }
  146. else bgw.ReportProgress(progressPercent, null);
  147. }
  148. else bgw.ReportProgress(progressPercent, null);
  149. return false;
  150. }
  151. #endregion
  152.  
  153. #region private methods
  154. private bool testName(string fileName)
  155. {
  156. return searchText == null
  157. || searchText.Equals(string.Empty)
  158. || fileName.ToUpper().Contains(searchText);
  159. }
  160. #endregion
  161. }
  162. }

Structure et Fichiers du projet

Afficher/masquer...


Répertoires contenus dans /var/www/bin/sniplets/bibliobrol/brolexplorer/model/ 
IcôneNomTailleModification
Pas de sous-répertoires.
IcôneNomTailleModification
| _ Répertoire parent0 octets1715984300 18/05/2024 00:18:20
Fichiers contenus dans /var/www/bin/sniplets/bibliobrol/brolexplorer/model/ 
IcôneNomTailleModificationAction
IcôneNomTailleModificationAction
Afficher le fichier .cs|.csDrive.cs6.66 Ko31/10/2018 18:32:21-refusé-
Afficher le fichier .cs|.csDirectoryTreeNode.cs2.79 Ko31/10/2018 18:32:21-refusé-
Afficher le fichier .cs|.csMediaBrowser.cs13.11 Ko31/10/2018 18:32:21-refusé-
Afficher le fichier .cs|.csMediaParser.cs5.71 Ko31/10/2018 18:32:21-refusé-

Utilisation de l'explorateur de code

  • Navigation :
    • Un clic sur une icône de répertoire ouvre ce répertoire pour en afficher les fichiers.
    • Lorsque le répertoire en cours ne contient pas de sous-répertoires il est possible de remonter vers le répertoire parent.
    • La structure de répertoires en treetable (tableau en forme d'arborescence) n'est plus possibledans cette version.
    • Un clic sur une icône de fichier ouvre ce fichier pour en afficher le code avec la coloration syntaxique adaptée en fonction du langage principal utilisé dans le fichier.
  • Affichage :
    • Il est possible de trier les répertoires ou les fichiers selon certains critères (nom, taille, date).
  • Actions :
    • Les actions possible sur les fichiers dépendent de vos droits d'utilisateur sur le site. Veuillez activer le mode utilisateur pour activer les actions.

English translation

You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.

If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.

Thank you in advance.

Document created the 30/10/2009, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/cs-brolexplorer-source-rf-model//MediaParser.cs.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.