1 //===- Stat.h -------------------------------------------------------------===// 2 // 3 // This source file is part of the Swift.org open source project 4 // 5 // Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors 6 // Licensed under Apache License v2.0 with Runtime Library Exception 7 // 8 // See http://swift.org/LICENSE.txt for license information 9 // See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef LLBUILD_BASIC_STAT_H 14 #define LLBUILD_BASIC_STAT_H 15 16 #include <sys/stat.h> 17 18 #include "llvm/Support/FileSystem.h" 19 20 namespace llbuild { 21 namespace basic { 22 namespace sys { 23 24 #if !defined(S_IFBLK) 25 #define S_IFBLK 0060000 26 #endif 27 #if !defined(S_IFIFO) 28 #define S_IFIFO 0010000 29 #endif 30 #if !defined(S_IFSOCK) 31 #define S_IFSOCK 00140000 32 #endif 33 #if !defined(S_IFLNK) 34 #define S_IFLNK 0120000 35 #endif 36 37 #if !defined(S_ISREG) 38 #define S_ISREG(mode) ((mode) & _S_IFMT) == S_IFREG 39 #endif 40 41 #if !defined(S_ISDIR) 42 #define S_ISDIR(mode) ((mode) & _S_IFMT) == S_IFDIR 43 #endif 44 45 #if !defined(S_ISBLK) 46 #define S_ISBLK(mode) ((mode) & _S_IFMT) == S_IFBLK 47 #endif 48 49 #if !defined(S_ISCHR) 50 #define S_ISCHR(mode) ((mode) & _S_IFMT) == S_IFCHR 51 #endif 52 53 #if !defined(S_ISFIFO) 54 #define S_ISFIFO(mode) ((mode) & _S_IFMT) == S_IFIFO 55 #endif 56 57 #if !defined(S_ISSOCK) 58 #define S_ISSOCK(mode) ((mode) & _S_IFMT) == S_IFSOCK 59 #endif 60 61 #if !defined(S_ISLNK) 62 #define S_ISLNK(mode) ((mode) & _S_IFMT) == S_IFLNK 63 #endif 64 65 #if defined(_WIN32) 66 using StatStruct = struct ::_stat; 67 #else 68 using StatStruct = struct ::stat; 69 #endif 70 71 int lstat(const char *fileName, StatStruct *buf); 72 int stat(const char *fileName, StatStruct *buf); 73 } 74 } 75 } 76 77 #endif // LLBUILD_BASIC_STAT_H 78