stat_windows.cc
Go to the documentation of this file.
1 //
2 // Copyright 2020 gRPC authors.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
18 
19 #ifdef GPR_WINDOWS_STAT
20 
21 #include <errno.h>
22 #include <sys/stat.h>
23 #include <sys/types.h>
24 
25 #include <grpc/support/log.h>
26 
28 
29 namespace grpc_core {
30 
31 absl::Status GetFileModificationTime(const char* filename, time_t* timestamp) {
32  GPR_ASSERT(filename != nullptr);
33  GPR_ASSERT(timestamp != nullptr);
34  struct _stat buf;
35  if (_stat(filename, &buf) != 0) {
36  const char* error_msg = strerror(errno);
37  gpr_log(GPR_ERROR, "_stat failed for filename %s with error %s.", filename,
38  error_msg);
39  return absl::Status(absl::StatusCode::kInternal, error_msg);
40  }
41  // Last file/directory modification time.
42  *timestamp = buf.st_mtime;
43  return absl::OkStatus();
44 }
45 
46 } // namespace grpc_core
47 
48 #endif // GPR_WINDOWS_STAT
filename
const char * filename
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:135
log.h
grpc_core
Definition: call_metric_recorder.h:31
buf
voidpf void * buf
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
absl::OkStatus
Status OkStatus()
Definition: third_party/abseil-cpp/absl/status/status.h:882
absl::StatusCode::kInternal
@ kInternal
grpc_core::GetFileModificationTime
absl::Status GetFileModificationTime(const char *filename, time_t *timestamp)
GPR_ASSERT
#define GPR_ASSERT(x)
Definition: include/grpc/impl/codegen/log.h:94
gpr_log
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
GPR_ERROR
#define GPR_ERROR
Definition: include/grpc/impl/codegen/log.h:57
stat.h
absl::Status
ABSL_NAMESPACE_BEGIN class ABSL_MUST_USE_RESULT Status
Definition: abseil-cpp/absl/status/internal/status_internal.h:36
absl::Status
Definition: third_party/abseil-cpp/absl/status/status.h:424
errno.h
port_platform.h


grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:17