Elliott Hughes | 5830577 | 2015-04-17 13:57:15 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 The Android Open Source Project |
| 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 | |
| 17 | #ifndef _ADB_UTILS_H_ |
| 18 | #define _ADB_UTILS_H_ |
| 19 | |
| 20 | #include <string> |
| 21 | |
Elliott Hughes | a7090b9 | 2015-04-17 17:03:59 -0700 | [diff] [blame] | 22 | bool getcwd(std::string* cwd); |
Elliott Hughes | 5830577 | 2015-04-17 13:57:15 -0700 | [diff] [blame] | 23 | bool directory_exists(const std::string& path); |
| 24 | |
Alex Vallée | 47d67c9 | 2015-05-06 16:26:00 -0400 | [diff] [blame^] | 25 | bool mkdirs(const std::string& path); |
Alex Vallée | 1421614 | 2015-05-06 17:22:25 -0400 | [diff] [blame] | 26 | |
Elliott Hughes | 5830577 | 2015-04-17 13:57:15 -0700 | [diff] [blame] | 27 | std::string escape_arg(const std::string& s); |
| 28 | |
Elliott Hughes | e67f1f8 | 2015-04-30 17:32:03 -0700 | [diff] [blame] | 29 | void dump_hex(const void* ptr, size_t byte_count); |
| 30 | |
Elliott Hughes | 3d5f60d | 2015-07-18 12:21:30 -0700 | [diff] [blame] | 31 | // Parses 'address' into 'host' and 'port'. |
| 32 | // If no port is given, takes the default from *port. |
| 33 | // 'canonical_address' then becomes "host:port" or "[host]:port" as appropriate. |
| 34 | // Note that no real checking is done that 'host' or 'port' is valid; that's |
| 35 | // left to getaddrinfo(3). |
| 36 | // Returns false on failure and sets *error to an appropriate message. |
| 37 | bool parse_host_and_port(const std::string& address, |
| 38 | std::string* canonical_address, |
| 39 | std::string* host, int* port, |
| 40 | std::string* error); |
| 41 | |
Elliott Hughes | 381cfa9 | 2015-07-23 17:12:58 -0700 | [diff] [blame] | 42 | int network_connect(const std::string& host, int port, int type, int timeout, std::string* error); |
| 43 | |
Elliott Hughes | 5830577 | 2015-04-17 13:57:15 -0700 | [diff] [blame] | 44 | #endif |