Changeset 2514 in ProjectBuilder for devel/pb-modules/lib/ProjectBuilder/Base.pm


Ignore:
Timestamp:
Apr 2, 2020, 2:44:50 AM (4 years ago)
Author:
Bruno Cornec
Message:

adds function pb_path_nbfiles to Base

File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb-modules/lib/ProjectBuilder/Base.pm

    r2498 r2514  
    4040
    4141our @ISA = qw(Exporter);
    42 our @EXPORT = qw(pb_mkdir_p pb_system pb_rm_rf pb_get_date pb_log pb_log_init pb_get_uri pb_get_content pb_set_content pb_display_file pb_syntax_init pb_syntax pb_temp_init pb_get_arch pb_get_osrelease pb_check_requirements pb_check_req pb_path_expand pb_exit $pbdebug $pbLOG $pbdisplaytype $pblocale);
     42our @EXPORT = qw(pb_mkdir_p pb_system pb_rm_rf pb_get_date pb_log pb_log_init pb_get_uri pb_get_content pb_set_content pb_display_file pb_syntax_init pb_syntax pb_temp_init pb_get_arch pb_get_osrelease pb_check_requirements pb_check_req pb_path_expand pb_path_nbfiles pb_exit $pbdebug $pbLOG $pbdisplaytype $pblocale);
    4343
    4444=pod
     
    593593}
    594594
     595=item B<pb_path_nbfiles>
     596
     597Return the number of files in a directory
     598
     599=cut
     600
     601sub pb_path_nbfiles {
     602
     603my $path = shift;
     604my $nb = 0;
     605
     606opendir(DIR,$path) || confess "Unable to open directory $path: $!";
     607foreach my $f (readdir(DIR)) {
     608    next if ($f =~ /^\.[\.]*$/);
     609    $nb++;
     610}
     611closedir(DIR);
     612
     613return($nb);
     614}
     615
    595616=back
    596617
Note: See TracChangeset for help on using the changeset viewer.