push_file_with_mask Subroutine

private subroutine push_file_with_mask(files, file_mask, path, build_dir, mask, dep_dirs)

Arguments

Type IntentOptional Attributes Name
type(string_t), intent(inout), allocatable :: files(:)
integer(kind=int64), intent(inout), allocatable :: file_mask(:)
character(len=*), intent(in) :: path
character(len=*), intent(in) :: build_dir
integer(kind=int64), intent(in) :: mask
type(string_t), intent(in), optional, allocatable :: dep_dirs(:)

Calls

proc~~push_file_with_mask~~CallsGraph proc~push_file_with_mask push_file_with_mask proc~vec_push_unique vec_push_unique proc~push_file_with_mask->proc~vec_push_unique exists exists proc~vec_push_unique->exists proc~is_ignored_path is_ignored_path proc~vec_push_unique->proc~is_ignored_path proc~is_in_dep_dirs is_in_dep_dirs proc~vec_push_unique->proc~is_in_dep_dirs proc~normalize_path normalize_path proc~vec_push_unique->proc~normalize_path proc~vec_grow vec_grow proc~vec_push_unique->proc~vec_grow proc~is_ignored_path->proc~normalize_path proc~contains_path_fragment contains_path_fragment proc~is_ignored_path->proc~contains_path_fragment proc~starts_with starts_with proc~is_ignored_path->proc~starts_with proc~is_in_dep_dirs->proc~normalize_path proc~is_in_dep_dirs->proc~starts_with proc~ends_with ends_with proc~contains_path_fragment->proc~ends_with

Called by

proc~~push_file_with_mask~~CalledByGraph proc~push_file_with_mask push_file_with_mask proc~compute_watch_files_from_settings compute_watch_files_from_settings proc~compute_watch_files_from_settings->proc~push_file_with_mask proc~rebuild_watch_list rebuild_watch_list proc~rebuild_watch_list->proc~compute_watch_files_from_settings proc~handle_manifest_change handle_manifest_change proc~handle_manifest_change->proc~rebuild_watch_list proc~watcher_init watcher_t%watcher_init proc~watcher_init->proc~rebuild_watch_list proc~watcher_run watcher_t%watcher_run proc~watcher_run->proc~rebuild_watch_list proc~watcher_run->proc~handle_manifest_change

Source Code

   subroutine push_file_with_mask(files, file_mask, path, build_dir, mask, dep_dirs)
      type(string_t), allocatable, intent(inout) :: files(:)
      integer(int64), allocatable, intent(inout) :: file_mask(:)
      character(len=*), intent(in) :: path
      character(len=*), intent(in) :: build_dir
      integer(int64), intent(in) :: mask
      type(string_t), allocatable, intent(in), optional :: dep_dirs(:)

      type(string_t), allocatable :: buf(:)
      integer(int64), allocatable :: mbuf(:)
      integer :: n, cap, i

      if (.not. allocated(files)) then
         n = 0
         cap = 8
         allocate(buf(cap), mbuf(cap))
      else
         n = size(files)
         cap = max(8, n)
         allocate(buf(cap), mbuf(cap))
         do i = 1, n
            buf(i)%s = files(i)%s
            mbuf(i) = file_mask(i)
         end do
      end if

      if (present(dep_dirs)) then
         call vec_push_unique(buf, mbuf, n, cap, path, build_dir, mask, dep_dirs)
      else
         call vec_push_unique(buf, mbuf, n, cap, path, build_dir, mask)
      end if

      call finalize_vec(buf, mbuf, n, files, file_mask)

   contains

      subroutine finalize_vec(buf, mbuf, n, files, file_mask)
         type(string_t), allocatable, intent(inout) :: buf(:)
         integer(int64), allocatable, intent(inout) :: mbuf(:)
         integer, intent(in) :: n
         type(string_t), allocatable, intent(inout) :: files(:)
         integer(int64), allocatable, intent(inout) :: file_mask(:)
         type(string_t), allocatable :: out(:)
         integer(int64), allocatable :: outm(:)
         integer :: k

         if (allocated(files)) deallocate(files)
         if (allocated(file_mask)) deallocate(file_mask)

         if (n <= 0) then
            allocate(files(0), file_mask(0))
            deallocate(buf, mbuf)
            return
         end if

         allocate(out(n), outm(n))
         do k = 1, n
            call move_alloc(buf(k)%s, out(k)%s)
            outm(k) = mbuf(k)
         end do
         deallocate(buf, mbuf)
         call move_alloc(out, files)
         call move_alloc(outm, file_mask)
      end subroutine finalize_vec

   end subroutine push_file_with_mask