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

version» Context lines:

pike.git/src/modules/_Stdio/efuns.c:12:   #include "array.h"   #include "mapping.h"   #include "pike_macros.h"   #include "fd_control.h"   #include "threads.h"   #include "module_support.h"   #include "constants.h"   #include "backend.h"   #include "operators.h"   #include "builtin_functions.h" - #include "pike_security.h" +    #include "bignum.h"      #include "file_machine.h"   #include "file.h"      #ifdef HAVE_SYS_TYPES_H   #include <sys/types.h>   #endif   #include <sys/stat.h>   #ifdef HAVE_SYS_PARAM_H
pike.git/src/modules/_Stdio/efuns.c:402:    *!    *! @seealso    *! @[Stdio.Stat], @[Stdio.File->stat()]    */   void f_file_stat(INT32 args)   {    PIKE_STAT_T st;    int i, l;    struct pike_string *str;    -  VALID_FILE_IO("file_stat","read"); -  +     if(args<1)    SIMPLE_TOO_FEW_ARGS_ERROR("file_stat", 1);    if((TYPEOF(sp[-args]) != T_STRING) || sp[-args].u.string->size_shift)    SIMPLE_BAD_ARG_ERROR("file_stat", 1, "string(0..255)");       str = sp[-args].u.string;    l = (args>1 && !UNSAFE_IS_ZERO(sp+1-args))?1:0;       if (string_has_null(str)) {    /* Filenames with NUL are not supported. */
pike.git/src/modules/_Stdio/efuns.c:457:   void f_file_truncate(INT32 args)   {   #if defined(INT64)    INT64 len = 0;   #else    off_t len = 0;   #endif    struct pike_string *str;    int res;    -  VALID_FILE_IO("file_truncate","write"); -  +     if(args < 2)    SIMPLE_TOO_FEW_ARGS_ERROR("file_truncate", 2);    if(TYPEOF(sp[-args]) != T_STRING)    SIMPLE_BAD_ARG_ERROR("file_truncate", 1, "string");      #if defined (INT64)   #if defined (HAVE_FTRUNCATE64) || SIZEOF_OFF_T > SIZEOF_INT_TYPE    if(is_bignum_object_in_svalue(&Pike_sp[1-args])) {    if (!int64_from_bignum(&len, Pike_sp[1-args].u.object))    Pike_error ("Bad argument 2 to file_truncate(). Length too large.\n");
pike.git/src/modules/_Stdio/efuns.c:590: Inside #if defined(__NT__)
   char *path;    DWORD sectors_per_cluster = -1;    DWORD bytes_per_sector = -1;    DWORD free_clusters = -1;    DWORD total_clusters = -1;    char _p[4];    char *p = _p;    unsigned int free_sectors;    unsigned int total_sectors;    -  VALID_FILE_IO("filesystem_stat","read"); -  +     get_all_args( "filesystem_stat", args, "%s", &path );       if(sp[-1].u.string->len < 2 || path[1] != ':')    {    p = 0;    } else {    p[0] = path[0];    p[1] = ':';    p[2] = '\\';    p[3] = 0;
pike.git/src/modules/_Stdio/efuns.c:825:    *! @[mkdir()], @[Stdio.recursive_rm()]    */   void f_rm(INT32 args)   {    PIKE_STAT_T st;    INT32 i;    struct pike_string *str;       destruct_objects_to_destruct();    -  VALID_FILE_IO("rm","write"); -  +     if(!args)    SIMPLE_TOO_FEW_ARGS_ERROR("rm", 1);       if(TYPEOF(sp[-args]) != T_STRING)    SIMPLE_BAD_ARG_ERROR("rm", 1, "string");       str = sp[-args].u.string;       if (string_has_null(str)) {    /* Filenames with NUL are not supported. */
pike.git/src/modules/_Stdio/efuns.c:910:    *! @seealso    *! @[rm()], @[cd()], @[Stdio.mkdirhier()]    */   void f_mkdir(INT32 args)   {    struct pike_string *str;    int mode;    int i;    char *s, *s_dup;    -  VALID_FILE_IO("mkdir","write"); -  +     if(!args)    SIMPLE_TOO_FEW_ARGS_ERROR("mkdir", 1);       if(TYPEOF(sp[-args]) != T_STRING)    SIMPLE_BAD_ARG_ERROR("mkdir", 1, "string");       mode = 0777; /* &'ed with ~umask anyway. */       if(args > 1)    {
pike.git/src/modules/_Stdio/efuns.c:1060:    *! @[mkdir()], @[cd()]    */   #ifdef __NT__   void f_get_dir(INT32 args)   {    HANDLE dir;    WIN32_FIND_DATAW d;    struct string_builder sb;    struct pike_string *str=0;    -  VALID_FILE_IO("get_dir","read"); -  +     get_all_args("get_dir",args,".%T",&str);       if(!str) {    push_text(".");    str = Pike_sp[-1].u.string;    args++;    }       if (str->size_shift == 2) {    /* Filenames that are too wide are not supported. */
pike.git/src/modules/_Stdio/efuns.c:1346: Inside #if defined(USE_FDOPENDIR)
  {   #ifdef USE_FDOPENDIR    int dir_fd;   #endif    DIR *dir = NULL;   #ifdef HAVE_READDIR_R    ptrdiff_t name_max = -1;   #endif    struct pike_string *str=0;    -  VALID_FILE_IO("get_dir","read"); -  +     get_all_args("get_dir",args,".%N",&str);       if(!str) {   #if defined(__amigaos4__)    push_empty_string();   #else    push_text(".");   #endif    str = Pike_sp[-1].u.string;    args++;
pike.git/src/modules/_Stdio/efuns.c:1412:    *! Returns @expr{1@} for success, @expr{0@} (zero) otherwise.    *!    *! @seealso    *! @[getcwd()]    */   void f_cd(INT32 args)   {    INT32 i;    struct pike_string *str;    -  VALID_FILE_IO("cd","status"); -  +     if(!args)    SIMPLE_TOO_FEW_ARGS_ERROR("cd", 1);       if(TYPEOF(sp[-args]) != T_STRING)    SIMPLE_BAD_ARG_ERROR("cd", 1, "string");       str = sp[-args].u.string;       if (string_has_null(str)) {    /* Filenames with NUL are not supported. */
pike.git/src/modules/_Stdio/efuns.c:1518: Inside #if defined(HAVE_EXECVE) and #if defined(DECLARE_ENVIRON)
   struct mapping *en;   #ifdef DECLARE_ENVIRON    extern char **environ;   #endif       save_sp=sp-args;       if(args < 2)    SIMPLE_TOO_FEW_ARGS_ERROR("exece", 2);    - #ifdef PIKE_SECURITY -  if(!CHECK_SECURITY(SECURITY_BIT_SECURITY)) -  Pike_error("exece: permission denied.\n"); - #endif -  -  +     e=0;    en=0;    switch(args)    {    default:    if(TYPEOF(sp[2-args]) != T_MAPPING)    SIMPLE_BAD_ARG_ERROR("exece", 3, "mapping(string:string)");    en=sp[2-args].u.mapping;    mapping_fix_type_field(en);   
pike.git/src/modules/_Stdio/efuns.c:1645:   {    INT32 i;    struct pike_string *str1;    struct pike_string *str2;   #ifdef __NT__    int orig_errno = errno;    int err;    PIKE_STAT_T st;   #endif    -  VALID_FILE_IO("mv","write"); -  +     if(args<2)    SIMPLE_TOO_FEW_ARGS_ERROR("mv", 2);       if(TYPEOF(sp[-args]) != T_STRING)    SIMPLE_BAD_ARG_ERROR("mv", 1, "string");       if(TYPEOF(sp[-args+1]) != T_STRING)    SIMPLE_BAD_ARG_ERROR("mv", 2, "string");       str1 = sp[-args].u.string;