Skip to contents

open_project() and create_project() record the session in the project folder (.sessions/, one small file per process), so other sessions can see that the project is in use. close_project() removes the record; list_project_users() reports who has a project open and which runs are still being written; delete_project() removes a project folder, and refuses while somebody else uses it.

Usage

close_project(verbose = isVerbose())

list_project_users(path = get_project_root())

delete_project(path, force = FALSE, verbose = isVerbose())

Arguments

verbose

logical.

path

character, the project directory. delete_project() has no default.

force

logical. TRUE deletes a project that is in use or holds sealed entries.

Value

close_project() the settings in force before the call, invisibly, as open_project() does. list_project_users() a tibble, one row per session or run: kind, pid, hostname, user, since, state (alive or unknown), scenario, run, self. delete_project() TRUE when the project was removed, FALSE when path does not exist, invisibly.

Details

The record of a session that ended without closing the project is recognised by its process and ignored. A session on another machine, or any session when the ps package is not installed, cannot be checked; it is listed with state unknown and counts as a user.

delete_project() refuses

  • a folder that holds no project (no energyRt_registry.csv), and a folder that contains the working directory – force does not override these;

  • a project another session has open, or with a run still being written;

  • a project with sealed entries.

force = TRUE overrides the last two. The folder is renamed before it is removed, so a file held open by any process (on Windows) stops the deletion as a whole and leaves the project intact. A project open in this session is closed first. A path that does not exist returns FALSE and is not an error, so delete_project(path) followed by create_project(path) starts afresh.

close_project() returns the store paths to their defaults, a per-session temporary directory, and drops the scenarios of the project that getScenario() cached.

Examples

proj <- file.path(tempdir(), "project_demo")
create_project(proj, verbose = FALSE)
list_project_users(proj)
#> # A tibble: 1 × 9
#>   kind      pid hostname        user  since           state scenario run   self 
#>   <chr>   <int> <chr>           <chr> <chr>           <chr> <chr>    <chr> <lgl>
#> 1 session 71672 DESKTOP-GGPFUTO admin 2026-11-30T01:… alive NA       NA    TRUE 
close_project(verbose = FALSE)
delete_project(proj, verbose = FALSE)