Esempio n. 1
0
 // Check if file counts as a book.
 public bool isBook(string path)
 {
     if (BookEngine.getFormatFromName(path) != BookEngine.BookFormat.unknown)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 2
0
    // Recursive file search. ProgressProp is the proportion of the progress bar
    // that needs to be filled in by this part of the search.
    IEnumerator searchFiles(string root, float progressProp)
    {
        //print ("Searching in " + root);

        // Look for any books in this directory.
        List <string> f        = new List <string> ();
        List <string> suffixes = BookEngine.getAcceptedFormats();

        try
        {
            foreach (string suffix in suffixes)
            {
                f.AddRange(Directory.GetFiles(root, "*" + suffix));
            }
        }
        catch (Exception)
        {
        }

        foreach (string fname in f)
        {
            // print ("Found files " + fname +" in " + root);
            yield return(registerBook(fname));
        }

        yield return("check files");

        // Now check all subdirectories, dividing progress evenly amongst each.
        List <string> d = getDirectoriesIn(root);

        if (d != null)
        {
            foreach (string dname in d)
            {
                //      print ("Checking " + dname);
                yield return(searchFiles(dname, progressProp * 1.0f / d.Count));

                updateProgress();
            }
        }
    }