1 /** 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef __FUNCTIONALEXT_FILEPATH_UTIL_H__ 17 #define __FUNCTIONALEXT_FILEPATH_UTIL_H__ 18 19 #include <stdlib.h> 20 #include <limits.h> 21 #include <string.h> 22 23 #include "test.h" 24 25 #define STR_SLASH "/" 26 #define STR_FILE_TXT "file.txt" 27 #define STR_FILE_LINK_TXT "linkfile.txt" 28 #define STR_FILE_IN_TXT "file_in.txt" 29 #define STR_FILE_OUT_TXT "file_out.txt" 30 #define STR_FILE_FROM_TXT "fromfile.txt" 31 #define STR_FILE_TO_TXT "tofile.txt" 32 #define STR_FILE_SWAP "swapfile" 33 #define STR_FILE_SYNC_TXT "sync_file_range.txt" 34 #define STR_TEST_TXT "test.txt" 35 #define STR_STAT_TEST_TXT "stattest.txt" 36 #define STR_FREAD_TEST_TXT "Freadtest.txt" 37 #define STR_FPUTC_TXT "fputc.txt" 38 #define STR_VFSCANF_TXT "vfscanf.txt" 39 #define STR_FACCESSAT_TEST_TXT "faccessattest.txt" 40 #define STR_FCHOWNAT_TEST_TXT "fchownattest.txt" 41 #define STR_WRITE_TEST_TXT "test_write.txt" 42 43 #define FILE_ABSOLUTE_PATH(file_name, path) do { \ 44 if(!getcwd(path, sizeof(path))) { \ 45 t_error("%s getcwd for path failed\n", __func__); \ 46 return; \ 47 } \ 48 strncat(path, STR_SLASH, 1); \ 49 strncat(path, file_name, strlen(file_name)); \ 50 } while (0) 51 52 #define FILE_ABSOLUTE_DIR(path) do { \ 53 if(!getcwd(path, sizeof(path))) { \ 54 t_error("%s getcwd for dir failed\n", __func__); \ 55 return; \ 56 } \ 57 } while (0) 58 59 #endif 60