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

version» Context lines:

pike.git/src/modules/_Stdio/efuns.c:488:    str = sp[-args].u.string;       if (string_has_null(str)) {    /* Filenames with NUL are not supported. */    errno = ENOENT;    pop_n_elems(args);    push_int(0);    return;    }    - #ifdef __NT__ -  { -  HANDLE h = CreateFile(str->str, GENERIC_WRITE, -  FILE_SHARE_READ|FILE_SHARE_WRITE, -  NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); -  if(h == DO_NOT_WARN(INVALID_HANDLE_VALUE)) { -  errno = GetLastError(); -  res=-1; -  } else { -  LONG high; -  DWORD err; - #ifdef INT64 -  high = DO_NOT_WARN ((LONG) (len >> 32)); -  len &= ((INT64) 1 << 32) - 1; - #else -  high = 0; - #endif -  if (SetFilePointer(h, DO_NOT_WARN ((LONG) len), &high, FILE_BEGIN) == -  INVALID_SET_FILE_POINTER && -  (err = GetLastError()) != NO_ERROR) { -  errno = err; -  res = -1; -  } -  else if (!SetEndOfFile(h)) { -  errno = GetLastError(); -  res=-1; -  } -  else -  res = 0; -  CloseHandle(h); -  } -  } - #else /* !__NT__ */ - #ifdef HAVE_TRUNCATE64 -  res = truncate64 (str->str, len); - #else -  res=truncate(str->str, len); - #endif - #endif /* __NT__ */ +  res = fd_truncate(str->str, len);       pop_n_elems(args);       push_int(!res);   }      /*! @decl mapping(string:int) filesystem_stat(string path)    *!    *! Returns a mapping describing the properties of the filesystem    *! containing the path specified by @[path].