@@ -56,25 +56,45 @@ namespace iText.Commons.Utils {
5656 public static class FileUtil {
5757 private static int tempFileCounter = 0 ;
5858
59+ /// <summary>
60+ /// Gets the default windows font directory.
61+ /// </summary>
62+ /// <returns>the default windows font directory</returns>
5963 public static String GetFontsDir ( ) {
6064 String windir = Environment . GetEnvironmentVariable ( "windir" ) ;
6165 return windir != null ? Path . Combine ( windir , "fonts" ) : "" ;
6266 }
6367
68+ /// <summary>
69+ /// Checks whether there is a file at the provided path.
70+ /// </summary>
71+ /// <param name="path">the path to the file to be checked on existence</param>
72+ /// <returns><CODE>true</CODE> if such a file exists, otherwise <CODE>false</CODE></returns>
6473 public static bool FileExists ( String path ) {
6574 if ( ! String . IsNullOrEmpty ( path ) ) {
6675 return new FileInfo ( path ) . Exists ;
6776 }
6877 return false ;
6978 }
7079
80+ /// <summary>
81+ /// Checks whether there is a directory at the provided path.
82+ /// </summary>
83+ /// <param name="path">the path to the directory to be checked on existence</param>
84+ /// <returns>true if such a directory exists, otherwise false</returns>
7185 public static bool DirectoryExists ( String path ) {
7286 if ( ! String . IsNullOrEmpty ( path ) ) {
7387 return new DirectoryInfo ( path ) . Exists ;
7488 }
7589 return false ;
7690 }
7791
92+ /// <summary>
93+ /// Lists all the files located at the provided directory.
94+ /// </summary>
95+ /// <param name="path">path to the directory</param>
96+ /// <param name="recursive">if <CODE>true</CODE>, files from all the subdirectories will be returned</param>
97+ /// <returns>all the files located at the provided directory</returns>
7898 public static String [ ] ListFilesInDirectory ( String path , bool recursive ) {
7999 if ( ! String . IsNullOrEmpty ( path ) ) {
80100 DirectoryInfo dir = new DirectoryInfo ( path ) ;
@@ -92,10 +112,23 @@ public static String[] ListFilesInDirectory(String path, bool recursive) {
92112 return null ;
93113 }
94114
115+ /// <summary>
116+ /// Lists all the files located at the provided directory, which are accepted by the provided filter.
117+ /// </summary>
118+ /// <param name="path">path to the directory</param>
119+ /// <param name="filter">filter to accept files to be listed</param>
120+ /// <returns>all the files located at the provided directory, which are accepted by the provided filter</returns>
95121 public static FileInfo [ ] ListFilesInDirectoryByFilter ( String path , IFileFilter filter ) {
96122 return ListFilesInDirectoryByFilter ( path , false , filter ) ;
97123 }
98124
125+ /// <summary>
126+ /// Lists all the files located at the provided directory, which are accepted by the provided filter.
127+ /// </summary>
128+ /// <param name="path">path to the directory</param>
129+ /// <param name="recursive">if <CODE>true</CODE>, files from all the subdirectories will be returned</param>
130+ /// <param name="filter">filter to accept files to be listed</param>
131+ /// <returns>all the files located at the provided directory, which are accepted by the provided filter</returns>
99132 public static FileInfo [ ] ListFilesInDirectoryByFilter ( String path , bool recursive , IFileFilter filter ) {
100133 if ( ! String . IsNullOrEmpty ( path ) ) {
101134 DirectoryInfo dir = new DirectoryInfo ( path ) ;
@@ -123,6 +156,12 @@ public static Stream GetBufferedOutputStream(String filename) {
123156 return new FileStream ( filename , FileMode . Create ) ;
124157 }
125158
159+ /// <summary>
160+ /// Creates a temporary file at the provided path.
161+ /// </summary>
162+ /// <param name="path">path to the temporary file to be created. If it is a directory,
163+ /// then the temporary file will be created at this directory</param>
164+ /// <returns>the created temporary file</returns>
126165 public static FileInfo CreateTempFile ( String path ) {
127166 if ( DirectoryExists ( path ) ) {
128167 return new FileInfo ( path + Path . DirectorySeparatorChar + "pdf_" + Interlocked . Increment ( ref tempFileCounter ) ) ;
@@ -148,6 +187,10 @@ public static Stream WrapWithBufferedOutputStream(Stream outputStream)
148187 return outputStream ;
149188 }
150189
190+ /// <summary>
191+ /// Creates a directory at the provided path.
192+ /// </summary>
193+ /// <param name="outPath">path to the directory to be created</param>
151194 public static void CreateDirectories ( String outPath ) {
152195 Directory . CreateDirectory ( outPath ) ;
153196 }
0 commit comments