Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
temp_path.h
Go to the documentation of this file.
1// Copyright 2010-2024 Google LLC
2// Licensed under the Apache License, Version 2.0 (the "License");
3// you may not use this file except in compliance with the License.
4// You may obtain a copy of the License at
5//
6// http://www.apache.org/licenses/LICENSE-2.0
7//
8// Unless required by applicable law or agreed to in writing, software
9// distributed under the License is distributed on an "AS IS" BASIS,
10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11// See the License for the specific language governing permissions and
12// limitations under the License.
13
14#ifndef OR_TOOLS_BASE_TEMP_PATH_H_
15#define OR_TOOLS_BASE_TEMP_PATH_H_
16
17#include <string>
18
19#include "absl/status/status.h"
20#include "absl/strings/string_view.h"
21#include "ortools/base/file.h"
22
23class TempPath {
24 public:
25 // default mode to create directories (a+rwx):
26 static constexpr int kDefaultMode = 0777;
27
28 explicit TempPath(absl::string_view prefix);
29 TempPath(absl::string_view prefix, absl::Status* status);
30
31 // TempPath is moveable, but not copyable.
32 TempPath(TempPath&& rhs);
33 TempPath(const TempPath& rhs) = delete;
35 TempPath& operator=(const TempPath& rhs) = delete;
36
37 ~TempPath();
38
39 // Returns the path which was created by this object.
40 std::string path() const { return path_; }
41
42 enum Location {
44 };
45
46 static TempPath* Create(Location location);
47
48 private:
49 // Internal constructor for Create* methods.
50 TempPath(const std::string& dirname, file::Options options,
51 absl::Status* status);
52
53 // Shared initialization among constructors.
54 // Makes directory given by path() and `options`.
55 absl::Status Init(file::Options options);
56
57 std::string path_;
58};
59
60namespace file {} // namespace file
61
62#endif // OR_TOOLS_BASE_TEMP_PATH_H_
static TempPath * Create(Location location)
Definition temp_path.cc:56
static constexpr int kDefaultMode
default mode to create directories (a+rwx):
Definition temp_path.h:26
TempPath(const TempPath &rhs)=delete
TempPath(absl::string_view prefix)
Definition temp_path.cc:37
std::string path() const
Returns the path which was created by this object.
Definition temp_path.h:40
TempPath & operator=(const TempPath &rhs)=delete
TempPath & operator=(TempPath &&rhs)
Definition temp_path.cc:48
absl::Status status
Definition g_gurobi.cc:44
Definition file.cc:169
int Options
Definition file.h:107