/**
  * List Files -- get_files() returns database records. This pulls from
  * the cloud instead but for completeness it will fetch local file names
  * from the database if the location is "local"
  *
  * @param	string	$location	The cloud provider or local
  * @param	string	$container	The container or folder to list files from
  * @return	array
  *
  **/
 public function listFiles($location = 'local', $container = '')
 {
     $i = 0;
     $files = array();
     // yup they want real live file names from the cloud
     if ($location !== 'local' and $container) {
         ci()->storage->load_driver($location);
         $cloud_list = ci()->storage->list_files($container);
         if ($cloud_list) {
             foreach ($cloud_list as $value) {
                 $this->_getFileInfo($value['name']);
                 if ($location === 'amazon-s3') {
                     // we'll create a path to store like rackspace does
                     $url = ci()->parser->parse_string(Setting::get('files_s3_url'), array('bucket' => $container), true);
                     $path = rtrim($url, '/') . '/' . $value['name'];
                 } elseif ($location === 'rackspace-cf') {
                     // fetch the cdn uri from Rackspace
                     $cf_container = ci()->storage->get_container($container);
                     $path = $cf_container['cdn_uri'];
                     // they are trying to index a non-cdn enabled container
                     if (!$cf_container['cdn_enabled']) {
                         // we'll try to enable it for them
                         if (!($path = ci()->storage->create_container($container, 'public'))) {
                             // epic fails all around!!
                             return $this->result(false, trans('files.enable_cdn'), $container);
                         }
                     }
                     $path = rtrim($path, '/') . '/' . $value['name'];
                 }
                 $files[$i]['filesize'] = (int) $value['size'] / 1000;
                 $files[$i]['filename'] = $value['name'];
                 $files[$i]['extension'] = $this->_ext;
                 $files[$i]['type'] = $this->_type;
                 $files[$i]['mimetype'] = $this->_mimetype;
                 $files[$i]['path'] = $path;
                 $files[$i]['date_added'] = $value['time'];
                 $i++;
             }
         }
     } elseif ($location === 'local') {
         // they're wanting a local list... give it to 'em but only if the file really exists
         $results = File::findBySlug($container);
         if ($results) {
             foreach ($results as $value) {
                 if (file_exists($this->path . $value->filename)) {
                     $files[$i]['filesize'] = $value->filesize;
                     $files[$i]['filename'] = $value->filename;
                     $files[$i]['extension'] = $value->extension;
                     $files[$i]['type'] = $value->type;
                     $files[$i]['mimetype'] = $value->mimetype;
                     $files[$i]['path'] = $value->path;
                     $files[$i]['date_added'] = $value->date_added;
                     $i++;
                 }
             }
         }
     }
     $message = $files ? null : trans('files.no_records_found');
     return $this->result((bool) $files, $message, null, $files);
 }