Skip to contents

Selects observations from a snapshot according to structural criteria such as paths, extensions, or exclusion patterns.

Usage

subset_snapshot(
  snapshot_path,
  folder_path,
  extensions = NULL,
  exclude_patterns = c("\\.Rcheck")
)

Arguments

snapshot_path

Character. Path to .rds snapshot file.

folder_path

Character vector. One or more folder roots.

extensions

Optional character vector of file extensions (no dot).

exclude_patterns

Optional regex patterns to exclude paths.

Value

data.frame filtered snapshot with rel_root_path

Details

The function performs observational selection only and does not derive Record Sets, contextual hierarchies, or analytical groupings.

The function returns a subset of the original snapshot while preserving its observational provenance (e.g. created_by, created_at).

In addition, it derives a rel_root_path column, which represents the path of each file relative to the matched filter root. When multiple folder_path values are provided, the deepest matching root is used.

The rel_root_path is a context-dependent projection intended for grouping, navigation, and reporting. It is not a stable identifier and should not be used for joins or identity; use rel_path for that purpose.

Examples

data("fscontextdemo_snapshot_02")

tmp <- tempfile(fileext = ".rds")
saveRDS(fscontextdemo_snapshot_02, tmp)

subset_snapshot(
  snapshot_path = tmp,
  folder_path = "D:/_packages/fscontextdemo/R"
)
#>       storage_id person_id
#> 76 fscontextdemo demo_user
#> 77 fscontextdemo demo_user
#> 78 fscontextdemo demo_user
#> 79 fscontextdemo demo_user
#>                                                   full_path
#> 76  D:/_packages/fscontextdemo/R/data-fsdemo_country_data.R
#> 77 D:/_packages/fscontextdemo/R/fscontextdemo_snapshot_01.R
#> 78               D:/_packages/fscontextdemo/R/hello_world.R
#> 79        D:/_packages/fscontextdemo/R/label_country_data.R
#>                         rel_path                    filename
#> 76  R/data-fsdemo_country_data.R  data-fsdemo_country_data.R
#> 77 R/fscontextdemo_snapshot_01.R fscontextdemo_snapshot_01.R
#> 78               R/hello_world.R               hello_world.R
#> 79        R/label_country_data.R        label_country_data.R
#>                         stem extension type size               mtime
#> 76  data-fsdemo_country_data         r file  487 2026-05-25 16:17:47
#> 77 fscontextdemo_snapshot_01         r file  891 2026-05-25 17:42:12
#> 78               hello_world         r file 1006 2026-05-25 16:08:03
#> 79        label_country_data         r file  969 2026-05-25 17:30:08
#>                  ctime               atime          birth_time depth links
#> 76 2026-05-25 16:17:53 2026-05-25 17:30:27 2026-05-25 16:17:12     2     1
#> 77 2026-05-25 17:42:21 2026-05-25 17:42:21 2026-05-25 17:11:24     2     1
#> 78 2026-05-25 16:08:03 2026-05-25 17:30:27 2026-05-25 15:55:55     2     1
#> 79 2026-05-25 17:33:20 2026-05-25 17:33:20 2026-05-25 17:26:17     2     1
#>    permissions quick_sig           scan_time                  repo_root
#> 76         rw-  487a477f 2026-05-25 17:46:40 D:/_packages/fscontextdemo
#> 77         rw-  416d04ba 2026-05-25 17:46:40 D:/_packages/fscontextdemo
#> 78         rw-  9d626c6a 2026-05-25 17:46:40 D:/_packages/fscontextdemo
#> 79         rw-  0ea2c9db 2026-05-25 17:46:40 D:/_packages/fscontextdemo
#>                    repo_rel_path git_tracked
#> 76  R/data-fsdemo_country_data.R        TRUE
#> 77 R/fscontextdemo_snapshot_01.R       FALSE
#> 78               R/hello_world.R        TRUE
#> 79        R/label_country_data.R        TRUE
#>                                 storage_path_id               rel_root_path
#> 76  fscontextdemo::R/data-fsdemo_country_data.R  data-fsdemo_country_data.R
#> 77 fscontextdemo::R/fscontextdemo_snapshot_01.R fscontextdemo_snapshot_01.R
#> 78               fscontextdemo::R/hello_world.R               hello_world.R
#> 79        fscontextdemo::R/label_country_data.R        label_country_data.R