pike.git / src / modules / _Stdio / efuns.c

version» Context lines:

pike.git/src/modules/_Stdio/efuns.c:1326:      /*! @decl string getcwd()    *!    *! Returns the current working directory.    *!    *! @seealso    *! @[cd()]    */   void f_getcwd(INT32 args)   { -  char *e; -  char *tmp; - #if defined(HAVE_WORKING_GETCWD) || !defined(HAVE_GETWD) -  INT32 size; -  -  size=1000; -  do { -  tmp=xalloc(size); -  e = getcwd(tmp,size); -  if (e || errno!=ERANGE) break; -  free(tmp); -  tmp=0; -  size*=2; -  } while (size < 10000); - #else - #ifndef MAXPATHLEN - #define MAXPATHLEN 32768 - #endif -  tmp=xalloc(MAXPATHLEN+1); -  THREADS_ALLOW_UID(); -  e = getwd(tmp); -  THREADS_DISALLOW_UID(); - #endif -  if(!e) { -  if (tmp) -  free(tmp); +  char *e = fd_get_current_dir_name(); +  if (!e) {    Pike_error("Failed to fetch current path.\n");    }       pop_n_elems(args);    push_text(e); -  free(tmp); +  free(e);   }      #ifdef HAVE_EXECVE   /*! @decl int exece(string file, array(string) args)    *! @decl int exece(string file, array(string) args, @    *! mapping(string:string) env)    *!    *! This function transforms the Pike process into a process running    *! the program specified in the argument @[file] with the arguments @[args].    *!