1*6fa2df46SAndroid Build Coastguard Worker // Copyright (C) 2021 The Android Open Source Project 2*6fa2df46SAndroid Build Coastguard Worker // 3*6fa2df46SAndroid Build Coastguard Worker // Licensed under the Apache License, Version 2.0 (the "License"); 4*6fa2df46SAndroid Build Coastguard Worker // you may not use this file except in compliance with the License. 5*6fa2df46SAndroid Build Coastguard Worker // You may obtain a copy of the License at 6*6fa2df46SAndroid Build Coastguard Worker // 7*6fa2df46SAndroid Build Coastguard Worker // http://www.apache.org/licenses/LICENSE-2.0 8*6fa2df46SAndroid Build Coastguard Worker // 9*6fa2df46SAndroid Build Coastguard Worker // Unless required by applicable law or agreed to in writing, software 10*6fa2df46SAndroid Build Coastguard Worker // distributed under the License is distributed on an "AS IS" BASIS, 11*6fa2df46SAndroid Build Coastguard Worker // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*6fa2df46SAndroid Build Coastguard Worker // See the License for the specific language governing permissions and 13*6fa2df46SAndroid Build Coastguard Worker // limitations under the License. 14*6fa2df46SAndroid Build Coastguard Worker 15*6fa2df46SAndroid Build Coastguard Worker #include <ditto/close_file.h> 16*6fa2df46SAndroid Build Coastguard Worker 17*6fa2df46SAndroid Build Coastguard Worker #include <ditto/logger.h> 18*6fa2df46SAndroid Build Coastguard Worker #include <ditto/shared_variables.h> 19*6fa2df46SAndroid Build Coastguard Worker 20*6fa2df46SAndroid Build Coastguard Worker namespace dittosuite { 21*6fa2df46SAndroid Build Coastguard Worker CloseFile(const Params & params,int input_fd_key)22*6fa2df46SAndroid Build Coastguard WorkerCloseFile::CloseFile(const Params& params, int input_fd_key) 23*6fa2df46SAndroid Build Coastguard Worker : Instruction(kName, params), input_fd_key_(input_fd_key) {} 24*6fa2df46SAndroid Build Coastguard Worker RunSingle()25*6fa2df46SAndroid Build Coastguard Workervoid CloseFile::RunSingle() { 26*6fa2df46SAndroid Build Coastguard Worker int fd = std::get<int>(SharedVariables::Get(input_fd_key_)); 27*6fa2df46SAndroid Build Coastguard Worker 28*6fa2df46SAndroid Build Coastguard Worker if (syscall_.Close(fd) != 0) { 29*6fa2df46SAndroid Build Coastguard Worker LOGF("Error while closing the file"); 30*6fa2df46SAndroid Build Coastguard Worker } 31*6fa2df46SAndroid Build Coastguard Worker } 32*6fa2df46SAndroid Build Coastguard Worker 33*6fa2df46SAndroid Build Coastguard Worker } // namespace dittosuite 34