private static void ProcessFile(File effDocFile, File outFile)
        {
            if (!effDocFile.exists())
            {
                throw new RuntimeException("file '" + effDocFile.GetAbsolutePath() + "' does not exist");
            }
            OutputStream os;
            try
            {
                os = new FileOutputStream(outFile);
            }
            catch (FileNotFoundException e)
            {
                throw new RuntimeException(e);
            }
            os = new SimpleAsciiOutputStream(os);
            PrintStream ps;
            try
            {
                ps = new PrintStream(os, true, "UTF-8");
            }
            catch (UnsupportedEncodingException e)
            {
                throw new RuntimeException(e);
            }

            outputLicenseHeader(ps);
            Type genClass = typeof(ExcelFileFormatDocFunctionExtractor);
            ps.println("# Created by (" + genClass.Name + ")");
            // identify the source file
            ps.print("# from source file '" + SOURCE_DOC_FILE_NAME + "'");
            ps.println(" (size=" + effDocFile.Length + ", md5=" + GetFileMD5(effDocFile) + ")");
            ps.println("#");
            ps.println("#Columns: (index, name, minParams, maxParams, returnClass, paramClasses, isVolatile, hasFootnote )");
            ps.println("");
            try
            {
                ZipFile zf = new ZipFile(effDocFile);
                InputStream is1 = zf.GetInputStream(zf.GetEntry("content.xml"));
                extractFunctionData(new FunctionDataCollector(ps), is1);
                zf.Close();
            }
            catch (ZipException e)
            {
                throw new RuntimeException(e);
            }
            catch (IOException e)
            {
                throw new RuntimeException(e);
            }
            ps.Close();

            String canonicalOutputFileName;
            try
            {
                canonicalOutputFileName = outFile.GetCanonicalPath();
            }
            catch (IOException e)
            {
                throw new RuntimeException(e);
            }
            Console.WriteLine("Successfully output to '" + canonicalOutputFileName + "'");
        }
Exemple #2
0
 /**
  * Recursively collect classes from the supplied directory
  *
  * @param arg   the directory to search in
  * @param out   output
  * @param ptrn  the pattern (regexp) to filter found files
  */
 private static void collectTests(File root, File arg, List<String> out, String ptrn) {
     if (arg.isDirectory()) {
         for (File f : arg.listFiles()) {
             collectTests(root, f, out, ptrn);
         }
     } else {
         String path = arg.GetAbsolutePath();
         String prefix = root.GetAbsolutePath();
         String cls = path.Substring(prefix.Length + 1).Replace(File.separator, ".");
         if(cls.matches(ptrn)) out.Add(cls);
     }
 }