Added new blocks. With this extension now you can…
Get modified date
Format modified date. For example MM/dd/yyyy HH:mm:ss will return 10/10/2020 12:34:34.
(It supports many formats.)
Get file length (size in bytes)
Get content list from a folder (which contains both files and folders, with only their name: command.txt, data) It working fast: loading 4000 items took only 1-2s, it doesn’t lag.
thank you for your contribution
you might want to follow the naming conventions, which is UpperCamelCase for property, method and event names (i.e. the first letter should be a capital letter) and lowerCamelCase for parameter names
example:
rather than having a method name like isExist let me suggest you to rename it to Exists
GetFileList: Get only the files from a directory, with names.
GetFolderList: Get only foders from a directory, with names.
(Why don’t I put containsPath property to them? Because of there are no subdirectories’ files contained, you can easily make the full paths with join block [join(path + name)]. For subdirectories, use your logic or Taifun’s File extension.)
GetName: Returns to the name of the file from its path. For example /system/app/AutoDialer will return AutoDialer. Works with files and folders too.
Added protection against non-readable folders (like /cache). They were causing an error “Attempt to get length of a null array”. Created another block to check if a folder is accessible (for files use this with parent folder):
The block ExecuteLinuxCommand did not work properly. Commands with ’ or " in them returned to empty string and did nothing. Like cp -r ‘/system/app’ ‘/mnt/sdcard/system apps’ or echo “hello world”.
@SimpleFunction(description = “Execute a linux command. You can also use this for file options e.g. cp - copy mv - move rm - remove. Example: cp -r ‘/system/app’ ‘/mnt/sdcard/My Documents/systemapps’”)
public String ExecuteLinuxCommand(String command){
String s;
Process p;
String result = “”;
try {
p = Runtime.getRuntime().exec(new String{“sh”,"-c",command});
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((s = br.readLine()) != null)
result = result + s + System.lineSeparator();
p.waitFor();
p.destroy();
} catch (Exception e) {}
return result;
}
Why do I publish that? Because finding the right way take me hours.
First, as I know Kodular IDE is still not working so I am not able to get my code.
Second you can delete a folder by rm -r “/path/to/folder” command. You may have to use Juan Antonios’ shell extension as Kodular’s does not allow " in input.