ShizukuFileUtil is a utility class that provides file I/O control through various methods using Shizuku, a service that allows regular apps to use system APIs with ADB/root privileges. The class contains several static methods for file operations such as listing, reading, moving, removing, and copying files.
Description: Lists all files and directories in the specified path using the ls command.
- Parameters:
path- The path to the directory to list. - Returns:
AList<String>containing file and directory names, or an empty list if an error occurs.
Description: Checks if a file or directory exists in the given path by listing its contents.
- Parameters:
path- The path to check for existence. - Returns:
trueif the file or directory exists,falseotherwise.
Description: Reads the content of a file at the specified path using the cat command.
- Parameters:
path- The file path to read. - Returns:
The file content as aString, or an empty string if an error occurs.
Description: Reads file content from the specified path and writes it to an OutputStream.
- Parameters:
path- The file path to read. - Returns:
TheOutputStreamcontaining the file content.
Description: Reads the content of the file at the specified path and returns it as an InputStream.
- Parameters:
path- The file path to read. - Returns:
AnInputStreamcontaining the file content.
Description: Reads the content from a FileInputStream by reflecting the file path.
- Parameters:
stream- TheInputStream(must be aFileInputStream). - Returns:
The file content as aString, ornullif the input stream is not aFileInputStreamor if an error occurs.
Description: Writes content from an InputStream to a file, overwriting existing content.
- Parameters:
path- The path to the file.
stream- TheInputStreamcontaining the data to write. - Returns:
AFuture<Boolean>indicating whether the write operation succeeded.
Description: Writes a string content to a file, overwriting existing content.
- Parameters:
path- The path to the file.
content- The content to write. - Returns:
AFuture<Boolean>indicating whether the write operation succeeded.
Description: Moves a file or directory to a new location.
- Parameters:
oldPath- The source path.
newPath- The destination path. - Returns:
AFuture<Boolean>indicating whether the move operation succeeded.
Description: Deletes a file at the specified path.
- Parameters:
path- The path to the file. - Returns:
AFuture<Boolean>indicating whether the delete operation succeeded.
Description: Executes a shell command and determines success or failure.
- Parameters:
command- The command to execute. - Returns:
AFuture<Boolean>indicating the success or failure of the command.