Return a File object representing the pathname to our session persistence directory, if any. The directory will be created if it does not already exist.
()
| 306 | * be created if it does not already exist. |
| 307 | */ |
| 308 | private synchronized File directory() throws IOException { |
| 309 | // Synchronised to avoid concurrent attempts to create the directory. |
| 310 | if (this.directory == null) { |
| 311 | return null; |
| 312 | } |
| 313 | if (this.directoryFile != null) { |
| 314 | return this.directoryFile; |
| 315 | } |
| 316 | File file = new File(this.directory); |
| 317 | if (!file.isAbsolute()) { |
| 318 | Context context = manager.getContext(); |
| 319 | ServletContext servletContext = context.getServletContext(); |
| 320 | File work = (File) servletContext.getAttribute(ServletContext.TEMPDIR); |
| 321 | file = new File(work, this.directory); |
| 322 | } |
| 323 | if (!file.exists() || !file.isDirectory()) { |
| 324 | if (!file.delete() && file.exists()) { |
| 325 | throw new IOException(sm.getString("fileStore.deleteFailed", file)); |
| 326 | } |
| 327 | if (!file.mkdirs() && !file.isDirectory()) { |
| 328 | throw new IOException(sm.getString("fileStore.createFailed", file)); |
| 329 | } |
| 330 | } |
| 331 | this.directoryFile = file; |
| 332 | return file; |
| 333 | } |
| 334 | |
| 335 | |
| 336 | /** |
no test coverage detected