private function _call()
    {

        // Time this
        $t = new Timer('Truecrypt Extension');

        // Deal with calling it
        try {
            $result = $this->_CallExt->exec('truecrypt', '-l -v');
        } catch (Exception $e) {
            // messed up somehow
            Errors::add('Truecrypt Extension', $e->getMessage());
            $this->_res = false;

            // Don't bother going any further
            return false;
        }

        // Store them here
        $this->_res = [];

        // Current one
        $curr = false;

        // Lines of output
        $lines = explode("\n", $result);

        // Go through each line
        for ($i = 0, $num = count($lines); $i < $num; ++$i) {

            // Extract juicy info
            if (!preg_match('/^([^:]+): ([^$]+)$/', $lines[$i], $line_match)) {
                continue;
            }

            // Decide what to do with that
            switch ($line_match[1]) {

                // It starts here
                case 'Slot':
                    if ($curr === false) {
                        $curr = array('slot' => $line_match[2]);
                    } elseif (is_array($curr)) {
                        $this->_res[] = $curr;
                        $curr = false;
                    }
                break;

                // Volume.
                case 'Volume':
                    if (is_array($curr)) {
                        $curr['volume'] = $line_match[2];
                    }
                break;

                // Virtual device
                case 'Virtual Device':
                    if (is_array($curr)) {
                        $curr['virtual_device'] = $line_match[2];
                    }
                break;

                // Where it might be mounted
                case 'Mount Directory':
                    if (is_array($curr)) {
                        $curr['mount_directory'] = $line_match[2];
                    }
                break;

                // Size of it
                case 'Size':
                    if (is_array($curr)) {
                        $curr['size'] = $line_match[2];
                    }
                break;

                // Is it read only?
                case 'Read-Only':
                    if (is_array($curr)) {
                        $curr['read_only'] = $line_match[2];
                    }
                break;

                // We deliberately ignore most keys for security reasons
                default:
                    continue;
                break;
            }
        }

        // Save a remaining one
        if (is_array($curr) && count($curr) > 0) {
            $this->_res[] = $curr;
        }

        // Apparent success
        return true;
    }
private function _call()
    {

        // Time this
        $t = new Timer('Truecrypt Extension');

        // Deal with calling it
        try {
            $result = $this->_CallExt->exec('truecrypt', '-l -v');
        } catch (Exception $e) {
            // messed up somehow
            Errors::add('Truecrypt Extension', $e->getMessage());
            $this->_res = false;

            // Don't bother going any further
            return false;
        }

        // Store them here
        $this->_res = [];

        // Current one
        $curr = false;

        // Lines of output
        $lines = explode("\n", $result);

        // Go through each line
        for ($i = 0, $num = count($lines); $i < $num; ++$i) {

            // Extract juicy info
            if (!preg_match('/^([^:]+): ([^$]+)$/', $lines[$i], $line_match)) {
                continue;
            }

            // Decide what to do with that
            switch ($line_match[1]) {

                // It starts here
                case 'Slot':
                    if ($curr === false) {
                        $curr = array('slot' => $line_match[2]);
                    } elseif (is_array($curr)) {
                        $this->_res[] = $curr;
                        $curr = false;
                    }
                break;

                // Volume.
                case 'Volume':
                    if (is_array($curr)) {
                        $curr['volume'] = $line_match[2];
                    }
                break;

                // Virtual device
                case 'Virtual Device':
                    if (is_array($curr)) {
                        $curr['virtual_device'] = $line_match[2];
                    }
                break;

                // Where it might be mounted
                case 'Mount Directory':
                    if (is_array($curr)) {
                        $curr['mount_directory'] = $line_match[2];
                    }
                break;

                // Size of it
                case 'Size':
                    if (is_array($curr)) {
                        $curr['size'] = $line_match[2];
                    }
                break;

                // Is it read only?
                case 'Read-Only':
                    if (is_array($curr)) {
                        $curr['read_only'] = $line_match[2];
                    }
                break;

                // We deliberately ignore most keys for security reasons
                default:
                    continue;
                break;
            }
        }

        // Save a remaining one
        if (is_array($curr) && count($curr) > 0) {
            $this->_res[] = $curr;
        }

        // Apparent success
        return true;
    }
private function _call ( ) { // Time this $ t = new Timer ( 'Truecrypt Extension' ) ; // Deal with calling it try { $ result = $ this -> _CallExt -> exec ( 'truecrypt' , '-l -v' ) ; } catch ( Exception $ e ) { // messed up somehow Errors :: add ( 'Truecrypt Extension' , $ e -> getMessage ( ) ) ; $ this -> _res = false ; // Don't bother going any further return false ; } // Store them here $ this -> _res = [ ] ; // Current one $ curr = false ; // Lines of output $ lines = explode ( "\n" , $ result ) ; // Go through each line for ( $ i = 0 , $ num = count ( $ lines ) ; $ i < $ num ; ++ $ i ) { // Extract juicy info if ( ! preg_match ( '/^([^:]+): ([^$]+)$/' , $ lines [ $ i ] , $ line_match ) ) { continue ; } // Decide what to do with that switch ( $ line_match [ 1 ] ) { // It starts here case 'Slot' : if ( $ curr === false ) { $ curr = array ( 'slot' => $ line_match [ 2 ] ) ; } elseif ( is_array ( $ curr ) ) { $ this -> _res [ ] = $ curr ; $ curr = false ; } break ; // Volume. case 'Volume' : if ( is_array ( $ curr ) ) { $ curr [ 'volume' ] = $ line_match [ 2 ] ; } break ; // Virtual device case 'Virtual Device' : if ( is_array ( $ curr ) ) { $ curr [ 'virtual_device' ] = $ line_match [ 2 ] ; } break ; // Where it might be mounted case 'Mount Directory' : if ( is_array ( $ curr ) ) { $ curr [ 'mount_directory' ] = $ line_match [ 2 ] ; } break ; // Size of it case 'Size' : if ( is_array ( $ curr ) ) { $ curr [ 'size' ] = $ line_match [ 2 ] ; } break ; // Is it read only? case 'Read-Only' : if ( is_array ( $ curr ) ) { $ curr [ 'read_only' ] = $ line_match [ 2 ] ; } break ; // We deliberately ignore most keys for security reasons default : continue ; break ; } } // Save a remaining one if ( is_array ( $ curr ) && count ( $ curr ) > 0 ) { $ this -> _res [ ] = $ curr ; } // Apparent success return true ; }
call truecrypt and parse it
call truecrypt and parse it