1 // 2 // Copyright (C) 2019 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 #include "filesystem_explorer.h" 17 18 #include <set> 19 #include <string> 20 21 #include <dirent.h> 22 #include <errno.h> 23 #include <sys/types.h> 24 25 #include <android-base/logging.h> 26 27 #include "common/libs/utils/files.h" 28 #include "common/libs/utils/environment.h" 29 #include "host/libs/config/fetcher_config.h" 30 31 namespace cuttlefish { 32 AvailableFilesReport()33FetcherConfig AvailableFilesReport() { 34 std::string current_directory = AbsolutePath(CurrentDirectory()); 35 FetcherConfig config; 36 37 if (FileExists(current_directory + "/fetcher_config.json")) { 38 config.LoadFromFile(current_directory + "/fetcher_config.json"); 39 return config; 40 } 41 42 // If needed check if `fetch_config.json` exists inside the $HOME directory. 43 // `assemble_cvd` will perform a similar check. 44 std::string home_directory = StringFromEnv("HOME", CurrentDirectory()); 45 std::string fetcher_config_path = home_directory + "/fetcher_config.json"; 46 if (FileExists(fetcher_config_path)) { 47 config.LoadFromFile(fetcher_config_path); 48 } 49 return config; 50 } 51 52 } // namespace cuttlefish 53