List Drupal files directory

This is how you can list files in Drupal 6 files directory

<?php

define
('TOOLS_CSV_FOLDER', "/tools/csv/");

function
tools_get_users_csv() {
  global
$user;
 
 
$dest = file_directory_path();
 
$base_dir = $dest.TOOLS_CSV_FOLDER;

 
$csv_files = file_scan_directory("sites/default/files/tools/csv", $user->name.'.*\.csv$'); //

 
$output = array();
  foreach (
$csv_files as $file => $csv_file) {
   
?>

    <pre>
    <?php
        print_r
($csv_file);
        print
__FILE__. " ".__LINE__;
   
?>

    </pre>
    <?php // exit;
 
}
 
 
 
/*
  stdClass Object
(
    [filename] => sites/default/files/tools/csv/siteadmin_2013_04_15_13_33_45.csv
    [basename] => siteadmin_2013_04_15_13_33_45.csv
    [name] => siteadmin_2013_04_15_13_33_45
)
*/

 
return $output;
}
?>
Knowledge keywords: