get_current_dir_name.c 453 B

1234567891011121314151617
  1. // SPDX-License-Identifier: LGPL-2.1
  2. // Copyright (C) 2018, 2019 Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
  3. //
  4. #ifndef HAVE_GET_CURRENT_DIR_NAME
  5. #include "get_current_dir_name.h"
  6. #include <unistd.h>
  7. #include <stdlib.h>
  8. /* Android's 'bionic' library, for one, doesn't have this */
  9. char *get_current_dir_name(void)
  10. {
  11. char pwd[PATH_MAX];
  12. return getcwd(pwd, sizeof(pwd)) == NULL ? NULL : strdup(pwd);
  13. }
  14. #endif // HAVE_GET_CURRENT_DIR_NAME