/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dalvik.system;
import java.io.File;
/**
* Utility class to handle the setup of the core library's concept of
* what the "default temporary directory" is. Application code may
* call into this class with an appropriate base directory during its
* startup, as a reasonably easy way to get the standard property
* java.io.tmpdir
to point at something useful.
*
* @hide
*/
public class TemporaryDirectory {
/** system property name for the temporary directory */
private static final String PROPERTY = "java.io.tmpdir";
/** final path component name for the temporary directory */
private static final String PATH_NAME = "tmp";
/** whether a temporary directory has been configured yet */
private static boolean configured = false;
/**
* Convenience method which is equivalent to
* setupDirectory(new File(baseDir))
.
*
* @param baseDir the base directory of the temporary directory
*/
public static void setUpDirectory(String baseDir) {
setUpDirectory(new File(baseDir));
}
/**
* Sets up the temporary directory, but only if one isn't already
* defined for this process, and only if it is possible (e.g., the
* directory already exists and is read-write, or the directory
* can be created). This call will do one of three things:
*
*
UnsupportedOperationException
if the
* directory could not be created or accessed