// Path: app/src/main/java/be/ppareit/swiftp/Util.java
// abstract public class Util {
//     final static String TAG = Util.class.getSimpleName();
// 
//     public static byte byteOfInt(int value, int which) {
//         int shift = which * 8;
//         return (byte) (value >> shift);
//     }
// 
//     public static String ipToString(int address, String sep) {
//         if (address > 0) {
//             StringBuffer buf = new StringBuffer();
//             buf.append(byteOfInt(address, 0)).append(sep).append(byteOfInt(address, 1))
//                     .append(sep).append(byteOfInt(address, 2)).append(sep)
//                     .append(byteOfInt(address, 3));
//             Log.d(TAG, "ipToString returning: " + buf.toString());
//             return buf.toString();
//         } else {
//             return null;
//         }
//     }
// 
//     public static InetAddress intToInet(int value) {
//         byte[] bytes = new byte[4];
//         for (int i = 0; i < 4; i++) {
//             bytes[i] = byteOfInt(value, i);
//         }
//         try {
//             return InetAddress.getByAddress(bytes);
//         } catch (UnknownHostException e) {
//             // This only happens if the byte array has a bad length
//             return null;
//         }
//     }
// 
//     public static String ipToString(int address) {
//         if (address == 0) {
//             // This can only occur due to an error, we shouldn't blindly
//             // convert 0 to string.
//             Log.e(TAG, "ipToString won't convert value 0");
//             return null;
//         }
//         return ipToString(address, ".");
//     }
// 
//     public static String[] concatStrArrays(String[] a1, String[] a2) {
//         String[] retArr = new String[a1.length + a2.length];
//         System.arraycopy(a1, 0, retArr, 0, a1.length);
//         System.arraycopy(a2, 0, retArr, a1.length, a2.length);
//         return retArr;
//     }
// 
//     public static void sleepIgnoreInterrupt(long millis) {
//         try {
//             Thread.sleep(millis);
//         } catch (InterruptedException ignored) {
//         }
//     }
// 
//     /**
//      * Creates a SimpleDateFormat in the formatting used by ftp sever/client.
//      */
//     private static SimpleDateFormat createSimpleDateFormat() {
//         SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss", Locale.US);
//         df.setTimeZone(TimeZone.getTimeZone("UTC"));
//         return df;
//     }
// 
//     public static String getFtpDate(long time) {
//         SimpleDateFormat df = createSimpleDateFormat();
//         return df.format(new Date(time));
//     }
// 
//     public static Date parseDate(String time) throws ParseException {
//         SimpleDateFormat df = createSimpleDateFormat();
//         return df.parse(time);
//     }
// }


import java.io.File;
import android.util.Log;
import be.ppareit.swiftp.Util;
    @Override
    protected String makeLsString(File file) {      
        StringBuilder response = new StringBuilder();

        if (!file.exists()) {
            Log.i(TAG, "makeLsString had nonexistent file");
            return null;
        }

        // See Daniel Bernstein's explanation of /bin/ls format at:
        // http://cr.yp.to/ftp/list/binls.html
        // This stuff is almost entirely based on his recommendations.

        String lastNamePart = file.getName();
        // Many clients can't handle files containing these symbols
        if (lastNamePart.contains("*") || lastNamePart.contains("/")) {
            Log.i(TAG, "Filename omitted due to disallowed character");
            return null;
        } else {
            // The following line generates many calls in large directories
            // staticLog.l(Log.DEBUG, "Filename: " + lastNamePart);
        }

        String[] selectedTypes = sessionThread.getFormatTypes();   
        if(selectedTypes != null){
            for (int i = 0; i < selectedTypes.length; ++i) {
                String type = selectedTypes[i];
                if (type.equalsIgnoreCase("size")) {
                    response.append("Size=" + String.valueOf(file.length()) + ';');
                } else if (type.equalsIgnoreCase("modify")) {
// Path: app/src/main/java/be/ppareit/swiftp/Util.java
// abstract public class Util {
//     final static String TAG = Util.class.getSimpleName();
// 
//     public static byte byteOfInt(int value, int which) {
//         int shift = which * 8;
//         return (byte) (value >> shift);
//     }
// 
//     public static String ipToString(int address, String sep) {
//         if (address > 0) {
//             StringBuffer buf = new StringBuffer();
//             buf.append(byteOfInt(address, 0)).append(sep).append(byteOfInt(address, 1))
//                     .append(sep).append(byteOfInt(address, 2)).append(sep)
//                     .append(byteOfInt(address, 3));
//             Log.d(TAG, "ipToString returning: " + buf.toString());
//             return buf.toString();
//         } else {
//             return null;
//         }
//     }
// 
//     public static InetAddress intToInet(int value) {
//         byte[] bytes = new byte[4];
//         for (int i = 0; i < 4; i++) {
//             bytes[i] = byteOfInt(value, i);
//         }
//         try {
//             return InetAddress.getByAddress(bytes);
//         } catch (UnknownHostException e) {
//             // This only happens if the byte array has a bad length
//             return null;
//         }
//     }
// 
//     public static String ipToString(int address) {
//         if (address == 0) {
//             // This can only occur due to an error, we shouldn't blindly
//             // convert 0 to string.
//             Log.e(TAG, "ipToString won't convert value 0");
//             return null;
//         }
//         return ipToString(address, ".");
//     }
// 
//     public static String[] concatStrArrays(String[] a1, String[] a2) {
//         String[] retArr = new String[a1.length + a2.length];
//         System.arraycopy(a1, 0, retArr, 0, a1.length);
//         System.arraycopy(a2, 0, retArr, a1.length, a2.length);
//         return retArr;
//     }
// 
//     public static void sleepIgnoreInterrupt(long millis) {
//         try {
//             Thread.sleep(millis);
//         } catch (InterruptedException ignored) {
//         }
//     }
// 
//     /**
//      * Creates a SimpleDateFormat in the formatting used by ftp sever/client.
//      */
//     private static SimpleDateFormat createSimpleDateFormat() {
//         SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss", Locale.US);
//         df.setTimeZone(TimeZone.getTimeZone("UTC"));
//         return df;
//     }
// 
//     public static String getFtpDate(long time) {
//         SimpleDateFormat df = createSimpleDateFormat();
//         return df.format(new Date(time));
//     }
// 
//     public static Date parseDate(String time) throws ParseException {
//         SimpleDateFormat df = createSimpleDateFormat();
//         return df.parse(time);
//     }
// }


// Path: app/src/main/java/be/ppareit/swiftp/server/CmdMLSD.java
import java.io.File;
import android.util.Log;
import be.ppareit.swiftp.Util;

    @Override
    protected String makeLsString(File file) {      
        StringBuilder response = new StringBuilder();

        if (!file.exists()) {
            Log.i(TAG, "makeLsString had nonexistent file");
            return null;
        }

        // See Daniel Bernstein's explanation of /bin/ls format at:
        // http://cr.yp.to/ftp/list/binls.html
        // This stuff is almost entirely based on his recommendations.

        String lastNamePart = file.getName();
        // Many clients can't handle files containing these symbols
        if (lastNamePart.contains("*") || lastNamePart.contains("/")) {
            Log.i(TAG, "Filename omitted due to disallowed character");
            return null;
        } else {
            // The following line generates many calls in large directories
            // staticLog.l(Log.DEBUG, "Filename: " + lastNamePart);
        }

        String[] selectedTypes = sessionThread.getFormatTypes();   
        if(selectedTypes != null){
            for (int i = 0; i < selectedTypes.length; ++i) {
                String type = selectedTypes[i];
                if (type.equalsIgnoreCase("size")) {
                    response.append("Size=" + String.valueOf(file.length()) + ';');
                } else if (type.equalsIgnoreCase("modify")) {
                    String timeStr = Util.getFtpDate(file.lastModified());