File: id.R

package info (click to toggle)
r-cran-fs 1.6.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 744 kB
  • sloc: cpp: 1,288; ansic: 530; sh: 13; makefile: 2
file content (32 lines) | stat: -rw-r--r-- 739 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#' Lookup Users and Groups on a system
#'
#' These functions use the GETPWENT(3) and GETGRENT(3) system calls to query
#' users and groups respectively.
#'
#' @return They return their results in a `data.frame`. On windows both
#'   functions return an empty `data.frame` because windows does not have user
#'   or group ids.
#' @name id
#' @export
#' @examples
#' # list first 6 groups
#' head(group_ids())
#'
#' # list first 6 users
#' head(user_ids())
group_ids <- function() {
  res <- .Call(fs_groups_)
  res <- unique(res[order(res$group_id), ])
  row.names(res) <- NULL
  res
}


#' @rdname id
#' @export
user_ids <- function() {
  res <- .Call(fs_users_)
  res <- unique(res[order(res$user_id), ])
  row.names(res) <- NULL
  res
}