Exemplo n.º 1
0
 public void ScanFile(string file)
 {
     try
     {
         FileInfo fileInfo = new FileInfo(file);
         // send the file to all the classifiers.
         foreach (ClassifierRule classifier in MyOptions.FileClassifiers)
         {
             // Don't send file to classifier if interest level is not high enough
             if ((classifier.Triage == Triage.Red && InterestLevel > 2) ||
                 (classifier.Triage == Triage.Yellow && InterestLevel > 1) ||
                 (classifier.Triage == Triage.Green && InterestLevel > 0)
                 )
             {
                 continue;
             }
             FileClassifier fileClassifier = new FileClassifier(classifier);
             if (fileClassifier.ClassifyFile(fileInfo))
             {
                 return;
             }
             ;
         }
     }
     catch (FileNotFoundException e)
     {
         // If file was deleted by a separate application
         //  or thread since the call to TraverseTree()
         // then just continue.
         Mq.Trace(e.ToString());
         return;
     }
     catch (UnauthorizedAccessException e)
     {
         Mq.Trace(e.ToString());
         return;
     }
     catch (PathTooLongException)
     {
         Mq.Trace(file + " path was too long for me to look at.");
         return;
     }
     catch (Exception e)
     {
         Mq.Trace(e.ToString());
         return;
     }
 }
Exemplo n.º 2
0
 public void UpdateIcon()
 {
     if (isClicked)
     {
         GetComponent <Image>().color      = new Color32(64, 128, 224, 216);
         title.GetComponent <Text>().color = new Color32(255, 255, 255, 255);
         if (size != null)
         {
             size.GetComponent <Text>().color = new Color32(255, 255, 255, 255);
         }
         if (dateModified != null)
         {
             dateModified.GetComponent <Text>().color = new Color32(255, 255, 255, 255);
         }
     }
     else
     {
         GetComponent <Image>().color      = new Color32(255, 255, 255, 0);
         title.GetComponent <Text>().color = new Color32(0, 0, 0, 255);
         if (size != null)
         {
             size.GetComponent <Text>().color = new Color32(0, 0, 0, 255);
         }
         if (dateModified != null)
         {
             dateModified.GetComponent <Text>().color = new Color32(0, 0, 0, 255);
         }
     }
     icon.GetComponent <Image>().sprite = iconSprite;
     title.GetComponent <Text>().text   = info.Name;
     if (size != null)
     {
         if (info.IsFolder)
         {
             size.GetComponent <Text>().text = "--";
         }
         else
         {
             size.GetComponent <Text>().text = FileClassifier.GetFileSize(info.Size);
         }
     }
     if (dateModified != null)
     {
         dateModified.GetComponent <Text>().text = info.ModificationDate.ToString();
     }
 }
Exemplo n.º 3
0
 public void ScanFile(string file)
 {
     try
     {
         FileInfo fileInfo = new FileInfo(file);
         // send the file to all the classifiers.
         foreach (ClassifierRule classifier in MyOptions.FileClassifiers)
         {
             FileClassifier fileClassifier = new FileClassifier(classifier);
             if (fileClassifier.ClassifyFile(fileInfo))
             {
                 return;
             }
             ;
         }
     }
     catch (FileNotFoundException e)
     {
         // If file was deleted by a separate application
         //  or thread since the call to TraverseTree()
         // then just continue.
         Mq.Trace(e.ToString());
         return;
     }
     catch (UnauthorizedAccessException e)
     {
         Mq.Trace(e.ToString());
         return;
     }
     catch (PathTooLongException)
     {
         Mq.Trace(file + " path was too long for me to look at.");
         return;
     }
     catch (Exception e)
     {
         Mq.Trace(e.ToString());
         return;
     }
 }
Exemplo n.º 4
0
    public void Goto(string url, bool changeURL = true)
    {
        Debug.Log("Navigating to " + url);
        DirectoryInfo info = new DirectoryInfo(url);

        try {
            info.GetFiles();
        } catch (System.UnauthorizedAccessException) {
            Debug.LogWarning("You do not have permission to access this directory.");
            return;
        }
        //Debug.Log("Updating path bar");
        if (changeURL)
        {
            pathBar.GetComponent <PathBar>().DidChangeURL(url);
        }
        //Debug.Log("Clearing icons");
        foreach (GameObject i in icons)
        {
            Destroy(i);
        }
        icons.Clear();
        List <BrowserSortable> iconlist = new List <BrowserSortable>();

        //Debug.Log("Retrieving files");
        foreach (FileInfo file in info.GetFiles())
        {
            iconlist.Add(new BrowserSortable(file));
        }
        //Debug.Log("Retrieving directories");
        foreach (DirectoryInfo file in info.GetDirectories())
        {
            iconlist.Add(new BrowserSortable(file));
        }
        //Debug.Log("Sorting");
        SortEntries.WithType(sortType, iconlist);
        //Debug.Log("Creating entries");
        foreach (BrowserSortable icon in iconlist)
        {
            //Debug.Log("Creating " + icon.Name);
            GameObject obj = Instantiate(fileIconPrefab, transform).gameObject;
            obj.GetComponent <BrowserIcon>().info = icon;
            if (icon.IsFolder)
            {
                obj.GetComponent <BrowserIcon>().iconSprite = iconSprites.GetSprite("Folder");
            }
            else
            {
                obj.GetComponent <BrowserIcon>().iconSprite = iconSprites.GetSprite(FileClassifier.FileTypeNames[FileClassifier.GetFileType(icon.Extension)]);
            }
            obj.GetComponent <BrowserIcon>().basePath = url;
            obj.GetComponent <BrowserIcon>().UpdateIcon();
            icons.Add(obj);
        }
        scrollView.GetComponent <ScrollRect>().verticalNormalizedPosition = 1;
        //currentPath = url;
    }