void printDisk() { FATFS fs; FS_USAGE fs_usage; fsInfo(&fs); lcdPrintln("[Disk]"); lcdNl(); lcdPrint("format: "); switch(fs.fs_type) { case 0: lcdPrintln("unmounted"); break; case FS_FAT12: lcdPrintln("FAT12"); break; case FS_FAT16: lcdPrintln("FAT16"); break; case FS_FAT32: lcdPrintln("FAT32"); break; default: lcdPrint("Unknown: "); lcdPrintln(IntToStr(fs.fs_type,3,0)); break; } fsUsage(&fs, &fs_usage); lcdPrint("total: "); prettyPrintSize(fs_usage.total); lcdNl(); lcdPrint("free: "); prettyPrintSize(fs_usage.free); lcdNl(); lcdNl(); double usage = 1 - ((double)fs_usage.free / fs_usage.total); lcdPrint("usage: "); lcdPrint(IntToStr(usage*100,3,0)); lcdPrintln("%"); drawUsage(usage); }
int drawMain (int argc, char ** argv) { try { DrawTool dt; int opt_index = dt.processOptions (argc, argv); if (opt_index >= argc) { throw crispr::input_exception("No input file provided" ); } else { // get cracking and process that file return dt.processInputFile(argv[opt_index]); } } catch(crispr::input_exception& re) { std::cerr<<re.what()<<std::endl; drawUsage(); return 1; } catch(crispr::exception& ce ) { std::cerr<<ce.what()<<std::endl; return 1; } }
int DrawTool::processOptions (int argc, char ** argv) { try { int c; int index; static struct option long_options [] = { {"help", no_argument, NULL, 'h'}, {"outfile", required_argument, NULL, 'o'}, {"colour",required_argument,NULL,'c'}, {"bins", required_argument, NULL, 'b'}, {"format", required_argument, NULL, 'f'}, {"algorithm", required_argument, NULL, 'a'}, {"groups", required_argument, NULL, 'g'}, {0,0,0,0} }; bool algo = false, outformat = false; while((c = getopt_long(argc, argv, "hg:c:a:f:o:b:", long_options, &index)) != -1) { switch(c) { case 'h': { drawUsage (); exit(1); break; } case 'g': { generateGroupsFromString (optarg); break; } case 'o': { DT_OutputFile = optarg; if (DT_OutputFile[DT_OutputFile.length() - 1] != '/') { DT_OutputFile += '/'; } // check if our output folder exists struct stat file_stats; if (0 != stat(DT_OutputFile.c_str(),&file_stats)) { recursiveMkdir(DT_OutputFile); } break; } case 'c': { if (!strcmp(optarg, "red-blue") ) { DT_ColourType = RED_BLUE; } else if (!strcmp(optarg, "red-blue-green")) { DT_ColourType = RED_BLUE_GREEN; } else if (!strcmp(optarg, "blue-red")) { DT_ColourType = BLUE_RED; } else if (!strcmp(optarg, "green-blue-red")) { DT_ColourType = GREEN_BLUE_RED; } else { throw crispr::input_exception("Not a known color type"); } break; } case 'f': { DT_OutputFormat = optarg; outformat = true; break; } case 'a': { if (!strcmp(optarg, "dot") || !strcmp(optarg, "neato") || !strcmp(optarg, "fdp") || !strcmp(optarg, "sfdp") || !strcmp(optarg, "twopi") || !strcmp(optarg, "circo")) { DT_RenderingAlgorithm = optarg; } else { throw crispr::input_exception("Not a known Graphviz rendering algorithm"); } algo = true; break; } case 'b': { int i; if (from_string<int>(i, optarg, std::dec)) { if (i > 0) { DT_Bins = i; } else { throw crispr::input_exception("The number of bins of colour must be greater than 0"); } } else { throw crispr::runtime_exception(__FILE__, __LINE__, __PRETTY_FUNCTION__,"could not convert string to int"); } break; } default: { drawUsage(); exit(1); break; } } } if (!(algo & outformat) ) { throw crispr::input_exception("You must specify both -a and -f on the command line"); } } catch (crispr::input_exception& e) { std::cerr<<e.what()<<std::endl; drawUsage(); exit(1); } catch (crispr::runtime_exception& e) { std::cerr<<e.what()<<std::endl; exit(1); } return optind; }