1 /* Copyright 2015 The TensorFlow 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 16 #ifndef TENSORFLOW_STREAM_EXECUTOR_LIB_PATH_H_ 17 #define TENSORFLOW_STREAM_EXECUTOR_LIB_PATH_H_ 18 19 #include "tensorflow/core/lib/io/path.h" 20 #include "tensorflow/stream_executor/lib/stringpiece.h" 21 #include "tensorflow/stream_executor/platform/port.h" 22 23 namespace perftools { 24 namespace gputools { 25 namespace port { 26 27 using tensorflow::io::Dirname; 28 29 namespace internal { 30 // TODO(rspringer): Move to cc/implementation file. 31 // Not part of the public API. 32 string JoinPathImpl(std::initializer_list<port::StringPiece> paths); 33 } // namespace internal 34 35 // Join multiple paths together. 36 // JoinPath unconditionally joins all paths together. For example: 37 // 38 // Arguments | JoinPath 39 // ---------------------------+--------------------- 40 // '/foo', 'bar' | /foo/bar 41 // '/foo/', 'bar' | /foo/bar 42 // '/foo', '/bar' | /foo/bar 43 // '/foo', '/bar', '/baz' | /foo/bar/baz 44 // 45 // All paths will be treated as relative paths, regardless of whether or not 46 // they start with a leading '/'. That is, all paths will be concatenated 47 // together, with the appropriate path separator inserted in between. 48 // Arguments must be convertible to port::StringPiece. 49 // 50 // Usage: 51 // string path = file::JoinPath("/var/log", dirname, filename); 52 // string path = file::JoinPath(FLAGS_test_srcdir, filename); 53 template <typename... T> 54 inline string JoinPath(const T&... args) { 55 return internal::JoinPathImpl({args...}); 56 } 57 58 } // namespace port 59 } // namespace gputools 60 } // namespace perftools 61 62 #endif // TENSORFLOW_STREAM_EXECUTOR_LIB_PATH_H_ 63