MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / getStat

Method getStat

src/plugins/ftp/src/android/com/foxdebug/ftp/Ftp.java:992–1063  ·  view source on GitHub ↗
(JSONArray args, CallbackContext callback)

Source from the content-addressed store, hash-verified

990 }
991
992 public void getStat(JSONArray args, CallbackContext callback) {
993 cordova
994 .getThreadPool()
995 .execute(
996 new Runnable() {
997 public void run() {
998 try {
999 String ftpId = args.optString(0);
1000 String path = args.optString(1);
1001
1002 if (ftpId == null || ftpId.isEmpty()) {
1003 callback.error("FTP ID is required.");
1004 return;
1005 }
1006
1007 if (path == null || path.isEmpty()) {
1008 callback.error("Path is required.");
1009 return;
1010 }
1011
1012 FTPClient ftp = ftpProfiles.get(ftpId);
1013 if (ftp == null) {
1014 callback.error("FTP client not found.");
1015 return;
1016 }
1017
1018 FTPFile[] files = ftp.listFiles(path);
1019 if (files == null || files.length == 0) {
1020 callback.error("File not found.");
1021 return;
1022 }
1023
1024 FTPFile file = files[0];
1025 JSONObject stat = new JSONObject();
1026 stat.put("isFile", file.isFile());
1027 stat.put("isValid", file.isValid());
1028 stat.put("isUnknown", file.isUnknown());
1029 stat.put("isDirectory", file.isDirectory());
1030 stat.put("isLink", file.isSymbolicLink());
1031 stat.put("linkCount", file.getHardLinkCount());
1032 stat.put("length", file.getSize());
1033 stat.put("name", getBaseName(file.getName()));
1034 stat.put("lastModified", file.getTimestamp().getTimeInMillis());
1035 stat.put("link", file.getLink());
1036 stat.put("group", file.getGroup());
1037 stat.put("user", file.getUser());
1038 stat.put(
1039 "canWrite",
1040 file.hasPermission(
1041 FTPFile.USER_ACCESS,
1042 FTPFile.WRITE_PERMISSION
1043 )
1044 );
1045 stat.put(
1046 "canRead",
1047 file.hasPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION)
1048 );
1049

Callers

nothing calls this directly

Calls 1

executeMethod · 0.45

Tested by

no test coverage detected