Laszlo Csomor | 645dbc4 | 2016-12-01 12:56:43 +0000 | [diff] [blame^] | 1 | // Copyright 2016 The Bazel Authors. All rights reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | #include "third_party/ijar/platform_utils.h" |
| 16 | |
| 17 | #include <errno.h> |
| 18 | #include <limits.h> |
| 19 | #include <stdio.h> |
| 20 | |
| 21 | #ifdef COMPILER_MSVC |
| 22 | #else // not COMPILER_MSVC |
| 23 | #include <fcntl.h> |
| 24 | #include <sys/stat.h> |
| 25 | #include <unistd.h> |
| 26 | #endif // COMPILER_MSVC |
| 27 | |
| 28 | #include <string> |
| 29 | |
| 30 | namespace devtools_ijar { |
| 31 | |
| 32 | bool stat_file(const char* path, Stat* result) { |
| 33 | #ifdef COMPILER_MSVC |
| 34 | // TODO(laszlocsomor) 2016-12-01: implement this and other methods, in order |
| 35 | // to close https://github.com/bazelbuild/bazel/issues/2157. |
| 36 | fprintf(stderr, "Not yet implemented on Windows\n"); |
| 37 | return false; |
| 38 | #else // not COMPILER_MSVC |
| 39 | struct stat statst; |
| 40 | if (stat(path, &statst) < 0) { |
| 41 | return false; |
| 42 | } |
| 43 | result->total_size = statst.st_size; |
| 44 | result->file_mode = statst.st_mode; |
| 45 | result->is_directory = (statst.st_mode & S_IFDIR) != 0; |
| 46 | return true; |
| 47 | #endif // COMPILER_MSVC |
| 48 | } |
| 49 | |
| 50 | } // namespace devtools_ijar |