1 // Licensed to the Apache Software Foundation (ASF) under one
2 // or more contributor license agreements. See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership. The ASF licenses this file
5 // to you under the Apache License, Version 2.0 (the
6 // "License"); you may not use this file except in compliance
7 // with the License. You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing,
12 // software distributed under the License is distributed on an
13 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 // KIND, either express or implied. See the License for the
15 // specific language governing permissions and limitations
18 #include "arrow/filesystem/util_internal.h"
19 #include "arrow/buffer.h"
20 #include "arrow/result.h"
21 #include "arrow/status.h"
27 TimePoint
CurrentTimePoint() {
28 auto now
= std::chrono::system_clock::now();
30 std::chrono::duration_cast
<TimePoint::duration
>(now
.time_since_epoch()));
33 Status
CopyStream(const std::shared_ptr
<io::InputStream
>& src
,
34 const std::shared_ptr
<io::OutputStream
>& dest
, int64_t chunk_size
,
35 const io::IOContext
& io_context
) {
36 ARROW_ASSIGN_OR_RAISE(auto chunk
, AllocateBuffer(chunk_size
, io_context
.pool()));
39 ARROW_ASSIGN_OR_RAISE(int64_t bytes_read
,
40 src
->Read(chunk_size
, chunk
->mutable_data()));
41 if (bytes_read
== 0) {
45 RETURN_NOT_OK(dest
->Write(chunk
->data(), bytes_read
));
51 Status
PathNotFound(const std::string
& path
) {
52 return Status::IOError("Path does not exist '", path
, "'");
55 Status
NotADir(const std::string
& path
) {
56 return Status::IOError("Not a directory: '", path
, "'");
59 Status
NotAFile(const std::string
& path
) {
60 return Status::IOError("Not a regular file: '", path
, "'");
63 Status
InvalidDeleteDirContents(const std::string
& path
) {
64 return Status::Invalid(
65 "DeleteDirContents called on invalid path '", path
, "'. ",
66 "If you wish to delete the root directory's contents, call DeleteRootDirContents.");
69 FileSystemGlobalOptions global_options
;
71 } // namespace internal