Improved not exist file case.
This commit is contained in:
parent
25e0fb5f64
commit
bb25cfa96d
@ -393,11 +393,22 @@ public final class Logar
|
||||
*/
|
||||
public static void checkLogFiles(final File source)
|
||||
{
|
||||
Files files = FilesUtils.search(source, LOGFILE_PATTERN).sortByName();
|
||||
|
||||
for (File file : files)
|
||||
if (source == null)
|
||||
{
|
||||
checkLogFile(file);
|
||||
System.out.println("Undefined source.");
|
||||
}
|
||||
else if (source.exists())
|
||||
{
|
||||
System.out.println("Missing source to check.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Files files = FilesUtils.search(source, LOGFILE_PATTERN).sortByName();
|
||||
|
||||
for (File file : files)
|
||||
{
|
||||
checkLogFile(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -410,11 +421,22 @@ public final class Logar
|
||||
*/
|
||||
public static void checkSort(final File source) throws IOException
|
||||
{
|
||||
Files files = FilesUtils.search(source, LOGFILE_PATTERN).sortByName();
|
||||
|
||||
for (File file : files)
|
||||
if (source == null)
|
||||
{
|
||||
checkSortFile(file);
|
||||
System.out.println("Undefined source.");
|
||||
}
|
||||
else if (source.exists())
|
||||
{
|
||||
System.out.println("Missing source to check.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Files files = FilesUtils.search(source, LOGFILE_PATTERN).sortByName();
|
||||
|
||||
for (File file : files)
|
||||
{
|
||||
checkSortFile(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -483,12 +505,23 @@ public final class Logar
|
||||
*/
|
||||
public static void sort(final File source) throws IOException
|
||||
{
|
||||
Files files = FilesUtils.searchEndingWith(source, LOGFILE_PATTERN).removeHidden().sortByName();
|
||||
|
||||
for (File file : files)
|
||||
if (source == null)
|
||||
{
|
||||
System.out.println("== Sort for [" + file.getName() + "]");
|
||||
LogFile.sortLogFile(file);
|
||||
System.out.println("Undefined source.");
|
||||
}
|
||||
else if (source.exists())
|
||||
{
|
||||
System.out.println("Missing source to sort.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Files files = FilesUtils.searchEndingWith(source, LOGFILE_PATTERN).removeHidden().sortByName();
|
||||
|
||||
for (File file : files)
|
||||
{
|
||||
System.out.println("== Sort for [" + file.getName() + "]");
|
||||
LogFile.sortLogFile(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ public class FilesUtils
|
||||
Files result;
|
||||
|
||||
result = new Files();
|
||||
if (source != null)
|
||||
if ((source != null) && (source.exists()))
|
||||
{
|
||||
if (source.isFile())
|
||||
{
|
||||
@ -74,34 +74,6 @@ public class FilesUtils
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* List recursively.
|
||||
*
|
||||
* @param source
|
||||
* the source
|
||||
* @param extensions
|
||||
* the extensions
|
||||
* @return the files
|
||||
*/
|
||||
public static Files searchEndingWith(final File source, final String... extensions)
|
||||
{
|
||||
Files result;
|
||||
|
||||
result = new Files();
|
||||
|
||||
Files full = listRecursively(source);
|
||||
for (File file : full)
|
||||
{
|
||||
if (StringUtils.endsWithAny(file.getName(), extensions))
|
||||
{
|
||||
result.add(file);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search recursively.
|
||||
*
|
||||
@ -131,4 +103,32 @@ public class FilesUtils
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* List recursively.
|
||||
*
|
||||
* @param source
|
||||
* the source
|
||||
* @param extensions
|
||||
* the extensions
|
||||
* @return the files
|
||||
*/
|
||||
public static Files searchEndingWith(final File source, final String... extensions)
|
||||
{
|
||||
Files result;
|
||||
|
||||
result = new Files();
|
||||
|
||||
Files full = listRecursively(source);
|
||||
for (File file : full)
|
||||
{
|
||||
if (StringUtils.endsWithAny(file.getName(), extensions))
|
||||
{
|
||||
result.add(file);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user