| 1 |
import java.io.*; |
| 2 |
|
| 3 |
// Class to ensure that a specified directory heirarchy exists. |
| 4 |
// If it does not, then we shall make it. |
| 5 |
// If the directories end up existing, then we shall return |
| 6 |
// a File of the deepest one. |
| 7 |
|
| 8 |
public class IscreamFilePlacer { |
| 9 |
|
| 10 |
public IscreamFilePlacer(String webDir) { |
| 11 |
_webDir = webDir; |
| 12 |
} |
| 13 |
|
| 14 |
// Return the new path name if sucessful. |
| 15 |
public File makeDirs(String period, String machine, String report) { |
| 16 |
|
| 17 |
File root = new File(_webDir); |
| 18 |
|
| 19 |
File periodDir = new File(root, period); |
| 20 |
if (!periodDir.isDirectory() || !periodDir.exists()) { |
| 21 |
if (!periodDir.mkdir()) { |
| 22 |
return null; |
| 23 |
} |
| 24 |
} |
| 25 |
|
| 26 |
File machineDir = new File(periodDir, machine); |
| 27 |
if (!machineDir.isDirectory() || !machineDir.exists()) { |
| 28 |
if (!machineDir.mkdir()) { |
| 29 |
return null; |
| 30 |
} |
| 31 |
} |
| 32 |
|
| 33 |
File reportDir = new File(machineDir, report); |
| 34 |
if (!reportDir.isDirectory() || !reportDir.exists()) { |
| 35 |
if (!reportDir.mkdir()) { |
| 36 |
return null; |
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
return reportDir; |
| 41 |
|
| 42 |
} |
| 43 |
|
| 44 |
private String _webDir; |
| 45 |
} |