this repo has no description
at trunk 68 lines 1.8 kB view raw
1/* Copyright (c) Facebook, Inc. and its affiliates. (http://www.facebook.com) */ 2#pragma once 3 4#include <sys/types.h> 5 6#include "globals.h" 7 8namespace py { 9 10class File { 11 public: 12 // Return 0. Return -errno on error. 13 static int close(int fd); 14 15 // Return 1 if fd is a tty. Return 0 if it is not. Return -errno on error. 16 static int isatty(int fd); 17 18 // Return 1 if fd is a directory. Return 0 if it is not. Return -errno on 19 // error. 20 static int isDirectory(int fd); 21 22 // Return 1 if fd is inheritable. Return 0 if it is not. Return -errno on 23 // error. 24 static int isInheritable(int fd); 25 26 // Return opened fd. Return -errno on error. 27 static int open(const char* path, int flags, int mode); 28 29 // Return number of bytes read. Return -errno on error. 30 static ssize_t read(int fd, void* buffer, size_t count); 31 32 // Return 0. Return -errno on error. 33 static int setNoInheritable(int fd); 34 35 // Return resulting offset location from start of file. Return -errno on 36 // error. 37 static int64_t seek(int fd, int64_t offset, int whence); 38 39 // Return file size according to fstat. Return -errno on error. 40 static int64_t size(int fd); 41 42 // Return 0. Return -errno on error. 43 static int truncate(int fd, int64_t size); 44 45 // Return number of bytes written. Return -errno on error. 46 static ssize_t write(int fd, const void* buffer, size_t size); 47 48 // TODO(T61930691): Remove these flags in favor of a simpler interface like a 49 // mode string 50 51 // This should be non-zero (O_BINARY) on NT. 52 static const word kBinaryFlag; 53 54 static const word kCreate; 55 56 // This should be O_CLOEXEC on posix and O_NOINHERIT on NT. 57 static const word kNoInheritFlag; 58 59 static const word kTruncate; 60 61 static const word kWriteOnly; 62 63 static const word kStderr; 64 static const word kStdin; 65 static const word kStdout; 66}; 67 68} // namespace py