Lines Matching refs:mode

92 #  define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
96 # define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
100 # define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
104 # define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
108 # define S_ISDOOR(mode) 0
112 # define S_ISPORT(mode) 0
116 # define S_ISWHT(mode) 0
255 mode_t mode;
261 mode = (mode_t)value;
262 if ((unsigned long)mode != value) {
263 PyErr_SetString(PyExc_OverflowError, "mode out of range");
266 return mode;
274 mode_t mode = _PyLong_AsMode_t(omode); \
275 if ((mode == (mode_t)-1) && PyErr_Occurred()) \
277 return PyBool_FromLong(isfunc(mode)); \
282 "S_ISDIR(mode) -> bool\n\n"
283 "Return True if mode is from a directory.");
286 "S_ISCHR(mode) -> bool\n\n"
287 "Return True if mode is from a character special device file.");
290 "S_ISBLK(mode) -> bool\n\n"
291 "Return True if mode is from a block special device file.");
294 "S_ISREG(mode) -> bool\n\n"
295 "Return True if mode is from a regular file.");
298 "S_ISFIFO(mode) -> bool\n\n"
299 "Return True if mode is from a FIFO (named pipe).");
302 "S_ISLNK(mode) -> bool\n\n"
303 "Return True if mode is from a symbolic link.");
306 "S_ISSOCK(mode) -> bool\n\n"
307 "Return True if mode is from a socket.");
310 "S_ISDOOR(mode) -> bool\n\n"
311 "Return True if mode is from a door.");
314 "S_ISPORT(mode) -> bool\n\n"
315 "Return True if mode is from an event port.");
318 "S_ISWHT(mode) -> bool\n\n"
319 "Return True if mode is from a whiteout.");
323 "Return the portion of the file's mode that can be set by os.chmod().");
328 mode_t mode = _PyLong_AsMode_t(omode);
329 if ((mode == (mode_t)-1) && PyErr_Occurred())
331 return PyLong_FromUnsignedLong(mode & S_IMODE);
336 "Return the portion of the file's mode that describes the file type.");
341 mode_t mode = _PyLong_AsMode_t(omode);
342 if ((mode == (mode_t)-1) && PyErr_Occurred())
344 return PyLong_FromUnsignedLong(mode & S_IFMT);
351 filetype(mode_t mode)
354 if (S_ISREG(mode)) return '-';
355 if (S_ISDIR(mode)) return 'd';
356 if (S_ISLNK(mode)) return 'l';
358 if (S_ISBLK(mode)) return 'b';
359 if (S_ISCHR(mode)) return 'c';
360 if (S_ISFIFO(mode)) return 'p';
361 if (S_ISSOCK(mode)) return 's';
363 if (S_ISDOOR(mode)) return 'D';
364 if (S_ISPORT(mode)) return 'P';
365 if (S_ISWHT(mode)) return 'w';
371 fileperm(mode_t mode, char *buf)
373 buf[0] = mode & S_IRUSR ? 'r' : '-';
374 buf[1] = mode & S_IWUSR ? 'w' : '-';
375 if (mode & S_ISUID) {
376 buf[2] = mode & S_IXUSR ? 's' : 'S';
378 buf[2] = mode & S_IXUSR ? 'x' : '-';
380 buf[3] = mode & S_IRGRP ? 'r' : '-';
381 buf[4] = mode & S_IWGRP ? 'w' : '-';
382 if (mode & S_ISGID) {
383 buf[5] = mode & S_IXGRP ? 's' : 'S';
385 buf[5] = mode & S_IXGRP ? 'x' : '-';
387 buf[6] = mode & S_IROTH ? 'r' : '-';
388 buf[7] = mode & S_IWOTH ? 'w' : '-';
389 if (mode & S_ISVTX) {
390 buf[8] = mode & S_IXOTH ? 't' : 'T';
392 buf[8] = mode & S_IXOTH ? 'x' : '-';
397 "Convert a file's mode to a string of the form '-rwxrwxrwx'");
403 mode_t mode;
405 mode = _PyLong_AsMode_t(omode);
406 if ((mode == (mode_t)-1) && PyErr_Occurred())
409 buf[0] = filetype(mode);
410 fileperm(mode, &buf[1]);