/[gnump3d]/gnump3d/bin/gnump3d2
ViewVC logotype

Diff of /gnump3d/bin/gnump3d2

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.29 by skx, Mon Oct 27 14:57:01 2003 UTC revision 1.30 by skx, Mon Oct 27 15:33:30 2003 UTC
# Line 1264  sub getErrorPage( $ $ ) Line 1264  sub getErrorPage( $ $ )
1264  }  }
1265    
1266    
1267    
1268    #
1269    #  Taken from the Perl Cookbook.
1270    #
1271    sub fisher_yates_shuffle (@)
1272      {
1273        my $array = shift;
1274        my $i;
1275        for ($i = @$array; --$i; )
1276          {
1277            my $j = int rand ($i+1);
1278            next if $i == $j;
1279            @$array[$i,$j] = @$array[$j,$i];
1280          }
1281      }
1282    
1283    
1284    #
1285    #  Get a playlist for the given directory.
1286    #
1287    sub playlistForDirectory( $ )
1288    {
1289      my ( $dir, $recurse, $random ) = ( @_ );
1290    
1291      my @files = ();
1292    
1293      #
1294      # Read in the files for the playlist.
1295      #
1296      if ( $recursive )
1297        {
1298          @files = &filesInDirRecursively( $dir );
1299        }
1300      else
1301        {
1302          @files = &filesInDir( $dir );
1303        }
1304    
1305      if ( $random )
1306        {
1307          # permutes @array in place
1308          fisher_yates_shuffle( \@files );
1309        }
1310    
1311    
1312      #
1313      # Make sure that each file we include is an audio file.
1314      #
1315      my @results;
1316      foreach my $entry (@files )
1317        {
1318          next if ( ! isAudio( $entry ) );
1319          push @results, $entry;
1320        }
1321      
1322      return( join( "\n", @results ) );
1323    }
1324    
1325    
1326    
1327  #  #
1328  #  Return a fully formed playlist for the given directory.  #  Return a fully formed playlist for the given directory.
1329  #  #

Legend:
Removed from v.1.29  
changed lines
  Added in v.1.30

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26