| // Copyright 2010 Google Inc. All Rights Reserved. |
| File* OS::OpenFile(const char* name, bool writable) { |
| flags = (O_RDWR | O_CREAT | O_TRUNC); |
| int fd = open(name, flags, 0666); |
| return new LinuxFile(name, fd, true); |
| File* OS::FileFromFd(const char* name, int fd) { |
| return new LinuxFile(name, fd, false); |
| bool OS::FileExists(const char* name) { |
| if (stat(name, &st) == 0) { |
| return S_ISREG(st.st_mode); // TODO: Deal with symlinks? |
| bool OS::DirectoryExists(const char* name) { |
| if (stat(name, &st) == 0) { |
| return S_ISDIR(st.st_mode); // TODO: Deal with symlinks? |