• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
22 #include <android-base/macros.h>
23 
24 int usage(const char*, ...);
25 
26 void close_stdin();
27 
28 bool getcwd(std::string* cwd);
29 bool directory_exists(const std::string& path);
30 
31 // Return the user's home directory.
32 std::string adb_get_homedir_path();
33 
34 // Return the adb user directory.
35 std::string adb_get_android_dir_path();
36 
37 bool mkdirs(const std::string& path);
38 
39 std::string escape_arg(const std::string& s);
40 
41 std::string dump_hex(const void* ptr, size_t byte_count);
42 
43 std::string perror_str(const char* msg);
44 
45 bool set_file_block_mode(int fd, bool block);
46 
47 extern int adb_close(int fd);
48 
49 // Given forward/reverse targets, returns true if they look sane. If an error is found, fills
50 // |error| and returns false.
51 // Currently this only checks "tcp:" targets. Additional checking could be added for other targets
52 // if needed.
53 bool forward_targets_are_valid(const std::string& source, const std::string& dest,
54                                std::string* error);
55 
56 #endif
57