get_current_dir_name.c 451 B

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