Package com.brightcove.player.util
Class FileUtil.StrictMode
- java.lang.Object
-
- com.brightcove.player.util.FileUtil.StrictMode
-
-
Constructor Summary
Constructors Constructor Description StrictMode()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
delete(java.io.File path)
Deletes a file or folder, even if the folder is not empty.static boolean
exists(java.lang.String path)
Checks if specified path points to a file/directory that exists on the local filesystem.static java.io.File
getExternalDirectory(android.content.Context context, java.lang.String folderType, java.lang.String name)
Gets the path to a directory on the primary shared/external storage device where the application can place persistent files it owns.static boolean
isDirectory(java.lang.String path)
Checks if specified path points to a directory that exists on the local filesystem.static boolean
isFile(java.lang.String path)
Checks if specified path points to a file that exists on the local filesystem.static java.io.File
makeReadWriteDirectory(java.io.File path)
Checks if the specified path is a directory that can be read from and written into.
-
-
-
Method Detail
-
makeReadWriteDirectory
@NonNull public static java.io.File makeReadWriteDirectory(@Nullable java.io.File path)
Checks if the specified path is a directory that can be read from and written into. If the directory does not exist, then this method will try to create a readable/writable directory. The operation will be performed on an io thread to adhere to the strict mode policy. The calling thread will be blocked until the operation is complete.- Parameters:
path
- the path to check/create.- Returns:
- reference to the validated path.
- Throws:
java.lang.IllegalArgumentException
- if the download path is invalid or if the download path does not have read or write permissions.
-
getExternalDirectory
@NonNull public static java.io.File getExternalDirectory(@NonNull android.content.Context context, @Nullable java.lang.String folderType, @Nullable java.lang.String name)
Gets the path to a directory on the primary shared/external storage device where the application can place persistent files it owns. These files are internal to the applications, and not typically visible to the user as media.
Please note that this method will neither check if selected directory exists nor whether it is readable or writable.
The operation will be performed on an io thread to adhere to the strict mode policy. The calling thread will be blocked until the operation is complete.
- Parameters:
context
- the contextfolderType
- the type of files directory to return. May be null for the root of the files directory or one of the following constants for a subdirectory:Environment.DIRECTORY_MUSIC
,Environment.DIRECTORY_PODCASTS
,Environment.DIRECTORY_RINGTONES
,Environment.DIRECTORY_ALARMS
,Environment.DIRECTORY_NOTIFICATIONS
,Environment.DIRECTORY_PICTURES
, orEnvironment.DIRECTORY_MOVIES
.name
- an optional subfolder name within the selected folder type.- Returns:
- the path to the selected directory.
- See Also:
makeReadWriteDirectory(File)
-
delete
public static boolean delete(@NonNull java.io.File path)
Deletes a file or folder, even if the folder is not empty. The operation will be performed on an io thread to adhere to the strict mode policy. The calling thread will be blocked until the operation is complete.- Parameters:
path
- the path to be deleted.- Returns:
- false if the file or folder was found, but could not be deleted.
-
isFile
public static boolean isFile(@Nullable java.lang.String path)
Checks if specified path points to a file that exists on the local filesystem. The operation will be performed on an io thread to adhere to the strict mode policy. The calling thread will be blocked until the operation is complete.- Parameters:
path
- the string path to be checked.- Returns:
- true is the path points to a local file.
-
isDirectory
public static boolean isDirectory(@Nullable java.lang.String path)
Checks if specified path points to a directory that exists on the local filesystem. The operation will be performed on an io thread to adhere to the strict mode policy. The calling thread will be blocked until the operation is complete.- Parameters:
path
- the string path to be checked.- Returns:
- true is the path points to a local directory.
-
exists
public static boolean exists(@Nullable java.lang.String path)
Checks if specified path points to a file/directory that exists on the local filesystem. The operation will be performed on an io thread to adhere to the strict mode policy. The calling thread will be blocked until the operation is complete.- Parameters:
path
- the string path to be checked.- Returns:
- true is the path points to a local file or directory.
-
-