Get a writable root directory.

@param context context.
@return {@link File}.
192564
@NonNull
    public static File getAlbumRootPath(Context context) {
        if (sdCardIsAvailable()) {
            return new File(Environment.getExternalStorageDirectory(), CACHE_DIRECTORY);
        } else {
            return new File(context.getFilesDir(), CACHE_DIRECTORY);
        }
    }
91164
public File getWorkDir() {
    if (null == this.workDir) {
      File dir = new File(teBaseDir, "work");
      if (!dir.exists() && !dir.mkdir()) {
        throw new RuntimeException("Failed to create directory at "
                + dir.getAbsolutePath());
      }
      this.workDir = dir;
    }
    return workDir;
  }
275122
public File getDirectory(String sPath) {
        File  directory = new File(sPath);
        if (!directory.isDirectory()) {
            URL resource = FilterFileManager.class.getClassLoader().getResource(sPath);
            try {
                directory = new File(resource.toURI());
            } catch (Exception e) {
                LOG.error("Error accessing directory in classloader. path=" + sPath, e);
            }
            if (!directory.isDirectory()) {
                throw new RuntimeException(directory.getAbsolutePath() + " is not a valid directory");
            }
        }
        return directory;
    }
1075023
private File getSourceDirectory() throws IOException {
    File file = new File(source);
    if (!file.isDirectory()) {
      getLog().debug("Could not find directory at '" + source + "'");
    }
    return file.getCanonicalFile();
  }
213162
@TargetApi(Build.VERSION_CODES.FROYO)
    public static File getExternalFilesDirForMovies(Context context) {
        return context.getExternalFilesDir(Environment.DIRECTORY_MOVIES);
    }
1183168
public DirContext getReadOnlyContext() {
		if (!anonymousReadOnly) {
			return doGetContext(
                    authenticationSource.getPrincipal(),
                    authenticationSource.getCredentials(),
                    DONT_DISABLE_POOLING);
		}
		else {
			return createContext(getAnonymousEnv());
		}
	}
777609
@TargetApi(Build.VERSION_CODES.FROYO)
    public static File getExternalFilesDirForNotifications(Context context) {
        return context.getExternalFilesDir(Environment.DIRECTORY_NOTIFICATIONS);
    }
907219
public static File getFile(Context context, Uri uri) {
        if (uri != null) {
            String path = getPath(context, uri);
            if (path != null && isLocal(path)) {
                return new File(path);
            }
        }
        return null;
    }
17631
public File getWisdomRootDirectory() {
        File wisdom;
        if (wisdomDirectory == null) {
            wisdom = new File(buildDirectory, Constants.WISDOM_DIRECTORY_NAME);
        } else {
            this.getLog().debug("Using Wisdom Directory : " + wisdomDirectory.getAbsolutePath());
            wisdom = wisdomDirectory;
        }

        if (wisdom.mkdirs()) {
            this.getLog().debug(wisdom.getAbsolutePath() + " directory created.");
        }
        return wisdom;
    }
960906
private static File createReserveDiskCacheDir(Context context) {
		File cacheDir = StorageUtils.getCacheDirectory(context, false);
		File individualDir = new File(cacheDir, "uil-images");
		if (individualDir.exists() || individualDir.mkdir()) {
			cacheDir = individualDir;
		}
		return cacheDir;
	}
452202
private void markOutputDirSuccessful(JobContext context)
  throws IOException {
    if (outputPath != null) {
      FileSystem fileSys = outputPath.getFileSystem(context.getConfiguration());
      if (fileSys.exists(outputPath)) {
        // create a file in the folder to mark it
        Path filePath = new Path(outputPath, SUCCEEDED_FILE_NAME);
        fileSys.create(filePath).close();
      }
    }
  }
1096334
@javax.annotation.Nonnull
  public File getResourceDir() {
    @javax.annotation.Nonnull final File etc = new File(fileName.getParentFile(), "etc");
    etc.mkdirs();
    return etc;
  }
928750
public boolean locateFileToServe( FileRequestContext context ) throws IOException {
    context.file = new File( contentDir, context.path);
    
    // if the path is not on the file system, send a 404.
    if( !context.file.exists() ) {
      context.response.sendError(HttpServletResponse.SC_NOT_FOUND);
      return true;    
    }
    
    // redirect welcome files if needed.
    if( handleWelcomeRedirect(context) ) return true;
    
    // if the requested file is a directory, try to find the welcome file.
    if( context.file.isDirectory() ) {
      context.file = new File(context.file, "index.html");
    }
    
    // if the file does not exist, then terminate with a 404.
    if( !context.file.exists() ) {
      context.response.sendError(HttpServletResponse.SC_NOT_FOUND);
      return true;
    }
    
    return false;
  }
1128045
public File getResourceRoot() throws IOException {
	if (resourceRoot == null) {
	    resourceRoot = new File(_getResourceRoot(), "lucee-server");
	    if (!resourceRoot.exists()) resourceRoot.mkdirs();
	}
	return resourceRoot;
    }
544047
private String getTaskCacheDirectory(TaskControllerContext context) {
    // In the case of JVM reuse, the task specific directory
    // is different from what is set with respect with
    // env.workDir. Hence building this from the taskId everytime.
    String taskId = context.task.getTaskID().toString();
    File cacheDirForJob = context.env.workDir.getParentFile().getParentFile();
    if(context.task.isTaskCleanupTask()) {
      taskId = taskId + TaskTracker.TASK_CLEANUP_SUFFIX;
    }
    return new File(cacheDirForJob, taskId).getAbsolutePath(); 
  }
982044
public static String readFile(String filePath, TestContext context) {
        return new ReadFileResourceFunction().execute(Collections.singletonList(filePath), context);
    }
685486
public static File getInternalDir(Context context, String path, boolean createIfNecessary) {
		File filesDir = context.getFilesDir();
		File internalDir = new File(filesDir, path);
		if (!internalDir.exists() && createIfNecessary) {
			boolean succeed = internalDir.mkdirs();
			if (!succeed) {
				ApptentiveLog.w(UTIL, "Unable to create internal directory: %s", internalDir);
			}
		}
		return internalDir;
	}