77using System . Threading . Tasks ;
88using System . Xml . Serialization ;
99
10- // TODOS:
11- // Fix the generated casing in report.cs
10+ // TODO Fix the generated casing in report.cs
1211
1312namespace PdfAValidator
1413{
1514 public class PdfAValidator : IDisposable
1615 {
1716 public void Dispose ( )
1817 {
19- Directory . Delete ( _pathVeraPdfDirectory , true ) ;
18+ if ( ! _customVerapdfAndJavaLocations )
19+ Directory . Delete ( _pathVeraPdfDirectory , true ) ;
2020 }
2121
2222 /// <summary>
@@ -25,9 +25,9 @@ public void Dispose()
2525 /// <param name="pathToVeraPdfBin"></param>
2626 public PdfAValidator ( string pathToVeraPdfBin , string pathToJava )
2727 {
28- // TODO Test
2928 VeraPdfStarterScript = pathToVeraPdfBin ;
3029 PathJava = pathToJava ;
30+ _customVerapdfAndJavaLocations = true ;
3131 }
3232
3333 /// <summary>
@@ -36,8 +36,12 @@ public PdfAValidator(string pathToVeraPdfBin, string pathToJava)
3636 public PdfAValidator ( )
3737 { intiPathToVeraPdfBinAndJava ( ) ; }
3838
39+ private const string maskedQuote = "\" " ;
3940 private string _pathVeraPdfDirectory ;
4041 public string PathJava { private set ; get ; }
42+
43+ private bool _customVerapdfAndJavaLocations ;
44+
4145 public string VeraPdfStarterScript { private set ; get ; }
4246
4347 public bool Validate ( string pathToPdfFile )
@@ -47,7 +51,7 @@ public bool Validate(string pathToPdfFile)
4751
4852 public report ValidateWithDetailedReport ( string pathToPdfFile )
4953 {
50- var absolutePathToPdfFile = System . IO . Path . GetFullPath ( pathToPdfFile ) ;
54+ var absolutePathToPdfFile = Path . GetFullPath ( pathToPdfFile ) ;
5155
5256 if ( ! File . Exists ( absolutePathToPdfFile ) )
5357 {
@@ -66,7 +70,8 @@ public report ValidateWithDetailedReport(string pathToPdfFile)
6670 process . StartInfo . EnvironmentVariables [ "JAVACMD" ] = PathJava ;
6771 }
6872 var startInfo = process . StartInfo ;
69- var arguments = new [ ] { "\" " , absolutePathToPdfFile , "\" " } ;
73+ // http://docs.verapdf.org/cli/terminal/
74+ var arguments = new [ ] { maskedQuote , absolutePathToPdfFile , maskedQuote } ;
7075 startInfo . Arguments = string . Concat ( arguments ) ;
7176 process . Start ( ) ;
7277
@@ -93,7 +98,7 @@ private static string GetStreamOutput(StreamReader stream)
9398 return outputReadTask . Result ;
9499 }
95100
96- static T DeserializeXml < T > ( string sourceXML ) where T : class
101+ private static T DeserializeXml < T > ( string sourceXML ) where T : class
97102 {
98103 var serializer = new XmlSerializer ( typeof ( T ) ) ;
99104 T result = null ;
@@ -106,7 +111,7 @@ static T DeserializeXml<T>(string sourceXML) where T : class
106111 public static void SetLinuxFileExecuteable ( string filePath )
107112 {
108113 var chmodCmd = "chmod 700 " + filePath ;
109- var escapedArgs = chmodCmd . Replace ( " \" " , "\\ \" " ) ;
114+ var escapedArgs = chmodCmd . Replace ( maskedQuote , "\\ \" " ) ;
110115
111116 var process = new Process
112117 {
0 commit comments