Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include <stdio.h> | 11 #include <stdio.h> |
| 12 | 12 |
| 13 #ifndef WEBRTC_TEST_TESTSUPPORT_FILEUTILS_H_ | 13 #ifndef WEBRTC_TEST_TESTSUPPORT_FILEUTILS_H_ |
| 14 #define WEBRTC_TEST_TESTSUPPORT_FILEUTILS_H_ | 14 #define WEBRTC_TEST_TESTSUPPORT_FILEUTILS_H_ |
| 15 | 15 |
| 16 #include <string> | 16 #include <string> |
| 17 #include <vector> | |
| 17 | 18 |
| 18 namespace webrtc { | 19 namespace webrtc { |
| 19 namespace test { | 20 namespace test { |
| 20 | 21 |
| 21 // This is the "directory" returned if the ProjectPath() function fails | 22 // This is the "directory" returned if the ProjectPath() function fails |
| 22 // to find the project root. | 23 // to find the project root. |
| 23 extern const char* kCannotFindProjectRootDir; | 24 extern const char* kCannotFindProjectRootDir; |
| 24 | 25 |
| 25 // Creates and returns the absolute path to the output directory where log files | 26 // Creates and returns the absolute path to the output directory where log files |
| 26 // and other test artifacts should be put. The output directory is generally a | 27 // and other test artifacts should be put. The output directory is generally a |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 // hierarchy reflecting that path is assumed to be present. | 60 // hierarchy reflecting that path is assumed to be present. |
| 60 // extension - File extension, without the dot, i.e. "bmp" or "yuv". | 61 // extension - File extension, without the dot, i.e. "bmp" or "yuv". |
| 61 std::string ResourcePath(const std::string& name, | 62 std::string ResourcePath(const std::string& name, |
| 62 const std::string& extension); | 63 const std::string& extension); |
| 63 | 64 |
| 64 // Gets the current working directory for the executing program. | 65 // Gets the current working directory for the executing program. |
| 65 // Returns "./" if for some reason it is not possible to find the working | 66 // Returns "./" if for some reason it is not possible to find the working |
| 66 // directory. | 67 // directory. |
| 67 std::string WorkingDir(); | 68 std::string WorkingDir(); |
| 68 | 69 |
| 70 // Reads the content of a directory, clears |output| and adds a string in it for | |
| 71 // each found file or directory. Each entry is a path created by prepending | |
| 72 // |dir| to the file/directory name. Returns true if no error occurs. "." and | |
| 73 // ".." are never added in |output|. | |
| 74 bool ReadDirectory(std::string path, std::vector<std::string>* output); | |
|
kwiberg-webrtc
2017/05/29 12:11:36
Should the first argument be const std::string&? T
AleBzk
2017/05/29 13:04:48
Nope, I need a local copy to add a trailing / (or
kwiberg-webrtc
2017/05/30 08:28:12
OK, that makes sense.
AleBzk
2017/05/30 11:09:16
Acknowledged.
| |
| 75 | |
| 69 // Creates a directory if it not already exists. | 76 // Creates a directory if it not already exists. |
| 70 // Returns true if successful. Will print an error message to stderr and return | 77 // Returns true if successful. Will print an error message to stderr and return |
| 71 // false if a file with the same name already exists. | 78 // false if a file with the same name already exists. |
| 72 bool CreateDir(const std::string& directory_name); | 79 bool CreateDir(const std::string& directory_name); |
| 73 | 80 |
| 74 // Removes a directory, which must already be empty. | 81 // Removes a directory, which must already be empty. |
| 75 bool RemoveDir(const std::string& directory_name); | 82 bool RemoveDir(const std::string& directory_name); |
| 76 | 83 |
| 77 // Removes a file. | 84 // Removes a file. |
| 78 bool RemoveFile(const std::string& file_name); | 85 bool RemoveFile(const std::string& file_name); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 92 // but can also be an absolute path. The intention with this function is to pass | 99 // but can also be an absolute path. The intention with this function is to pass |
| 93 // the argv[0] being sent into the main function to make it possible for | 100 // the argv[0] being sent into the main function to make it possible for |
| 94 // fileutils.h to find the correct project paths even when the working directory | 101 // fileutils.h to find the correct project paths even when the working directory |
| 95 // is outside the project tree (which happens in some cases). | 102 // is outside the project tree (which happens in some cases). |
| 96 void SetExecutablePath(const std::string& path_to_executable); | 103 void SetExecutablePath(const std::string& path_to_executable); |
| 97 | 104 |
| 98 } // namespace test | 105 } // namespace test |
| 99 } // namespace webrtc | 106 } // namespace webrtc |
| 100 | 107 |
| 101 #endif // WEBRTC_TEST_TESTSUPPORT_FILEUTILS_H_ | 108 #endif // WEBRTC_TEST_TESTSUPPORT_FILEUTILS_H_ |
| OLD | NEW |