FileStatsParser.cs
Description du code
FileStatsParser.cs est un fichier du projet BrolFileStats.Ce fichier est situé dans /var/www/bin/sniplets/bibliobrol/brolfilestats/.
Projet BrolFileStats :
Statistiques en CSharp.
Code source ou contenu du fichier
Code c# (FileStatsParser.cs) (126 lignes)
using System; using System.Collections.Generic; using System.Text; using System.IO; using System.ComponentModel; using be.gaudry.model.file; using be.gaudry.view.controls; using be.gaudry.model; namespace be.gaudry.explorer.filestats.model { public class FileStatsParser : AbstractFileParser { #region declarations and constructors private Stat stat; private FILE_SEARCHTYPE searchType; private bool keySensitive, firstLevel; private Dictionary<string, DateTime> dateLaps; public FileStatsParser() : base() { firstLevel = true; dateLaps.Add("5 ans", DateTime.Now.AddYears(-5)); dateLaps.Add("Un an", DateTime.Now.AddYears(-1)); dateLaps.Add("6 mois", DateTime.Now.AddMonths(-6)); dateLaps.Add("Un mois", DateTime.Now.AddMonths(-1)); dateLaps.Add("15 jours", DateTime.Now.AddDays(-15)); dateLaps.Add("Une semaine", DateTime.Now.AddDays(-7)); dateLaps.Add("Aujourd'hui", DateTime.Now); } #endregion #region properties public Stat Stat { get { return stat; } set { stat = value; } } public FILE_SEARCHTYPE SearchType { get { return searchType; } set { searchType = value; } } public bool KeySensitive { get { return keySensitive; } set { keySensitive = value; } } /// <summary> /// Set true to show only first level summary /// </summary> public bool FirstLevel { get { return firstLevel; } set { firstLevel = value; } } public List<string> DateLaps { } #endregion #region method to implement /// <summary> /// Do something on each file /// </summary> /// <param name="bgw">BackgroundWorker to perform cancel if needed, and report progress</param> /// <param name="e">DoWorkEventArgs to perform cancel if needed, and report progress</param> /// <param name="fi">FileInfo to check</param> /// <param name="percent">(int) Progress percentage</param> /// <param name="subDirDeep">Deep of the directory in comparison with start directory</param> /// <returns> /// 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) /// false otherwise ///</returns> protected override bool performOnFile(BackgroundWorker bgw, DoWorkEventArgs e, FileInfo fi, int percent, int subDirDeep) { switch (searchType) { case FILE_SEARCHTYPE.Extension: stat.increase((keySensitive) ? fi.Extension : fi.Extension.ToUpper()); break; case FILE_SEARCHTYPE.Count: stat.increase(fi.DirectoryName); break; case FILE_SEARCHTYPE.LastAccess: DateTime dt = fi.LastAccessTime; foreach(KeyValuePair<string, DateTime> kvp in dateLaps) { if (dt <= kvp.Value) { stat.increase(kvp.Key); return false; } } break; case FILE_SEARCHTYPE.Attribute: stat.increase(fi.Attributes.ToString()); break; case FILE_SEARCHTYPE.FileSize: stat.increase(fi.FullName, fi.Length); break; case FILE_SEARCHTYPE.DirSize: string directoryName = fi.DirectoryName; if (fi.Directory.FullName.Equals(startPath)) { break; } if (firstLevel) { for (int i = 2; i <= subDirDeep; i++) { directoryName = FileHelper.getParentDir(directoryName); } } stat.increase(directoryName, fi.Length); break; } return false; } #endregion } }
Structure et Fichiers du projet
Afficher/masquer...Icône | Nom | Taille | Modification |
Pas de sous-répertoires. | |||
Icône | Nom | Taille | Modification |
| _ | Répertoire parent | 0 octets | 1734910831 23/12/2024 00:40:31 |
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-brolfilestats-source-rf-model//FileStatsParser.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.