Index: openacs-4/contrib/obsolete-packages/mp3-jukebox/tcl/scanner-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/obsolete-packages/mp3-jukebox/tcl/scanner-procs.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/contrib/obsolete-packages/mp3-jukebox/tcl/scanner-procs.tcl 17 Oct 2001 19:44:08 -0000 1.1 +++ openacs-4/contrib/obsolete-packages/mp3-jukebox/tcl/scanner-procs.tcl 5 Jul 2002 16:32:19 -0000 1.2 @@ -7,16 +7,60 @@ @cvs-id $Id$ } +ad_proc -private mp3_opendir { + dir + {file_type f} + {return_style short} +} { + Use: opendir dir ?file_type? ?return_style? + return a list of files or directories. + Arguments: dir Directory to return (required) + file_type "d" for directories, + "f" for files (default), + "a" for all + return_style "short" for filenames only, + "long" for full paths + Returns list of files/directories on success, "" on failure +} { + set temp_dirs "" + set temp_files "" + set files [glob -nocomplain "$dir/*"] + foreach file $files { + if {[file isfile $file] == 1} {lappend temp_files $file} + if {[file isdirectory $file] == 1} {lappend temp_dirs $file} + } + switch $file_type { + a { set out [concat $temp_files $temp_dirs]} + f { set out $temp_files } + d { set out $temp_dirs } + default {error "File type argument $file_type not known. Must be d f or a"} + } + switch $return_style { + long { return $out } + short { + set short_out "" + foreach file $out { + lappend short_out [file tail $file] + } + return $short_out + } + default {error "Return type argument $return_style not known. Must be short or long"} + } +} + + ad_proc -public get_list_of_mp3s { } { This proc uses the package_id to check an appropriate directory. It uses ad_parameter to check the MP3FileLocation variable. } { set package_id [ad_conn package_id] - set file_list [exec /usr/bin/find [ad_parameter -package_id $package_id MP3StagingLocation] ] + set staging_path [ad_parameter -package_id $package_id MP3StagingLocation] + # set file_list [exec /usr/bin/find [ad_parameter -package_id $package_id MP3StagingLocation] ] + set file_list [mp3_opendir $staging_path] return $file_list }