utils.h
1 // Copyright (C) 2013-2016 DNAnexus, Inc.
2 //
3 // This file is part of dx-toolkit (DNAnexus platform client libraries).
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License"); you may
6 // not use this file except in compliance with the License. You may obtain a
7 // copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 // License for the specific language governing permissions and limitations
15 // under the License.
16 
17 #ifndef __DXCPP_UTILS_H__
18 #define __DXCPP_UTILS_H__
19 
20 #include <string>
21 #include <vector>
22 
23 namespace dx {
27  std::string getUserHomeDirectory();
28 
29  std::string joinPath(const std::string &first_path,
30  const std::string &second_path,
31  const std::string &third_path="");
32 
33  // Returns MD5 hash (as a hex string) for the given vector<char>
34  std::string getHexifiedMD5(const std::vector<char> &inp);
35  std::string getHexifiedMD5(const unsigned char *ptr, const unsigned long size);
36  std::string getHexifiedMD5(const std::string &inp);
37 
38  namespace _internal {
39  // Sleep for "duration" seconds using nanosleep (for posix systems)
40  // and using boost::this_thread::sleep() on windows
41  int sleepUsingNanosleep(unsigned int sec);
42  }
43 }
44 
45 #endif
An executable object that can be published for others to discover.
Definition: api.cc:7