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 #ifndef PREFERENCES_ADAPTOR_H 16 #define PREFERENCES_ADAPTOR_H 17 18 #ifndef FILE_MODE 19 #define FILE_MODE 0771 20 #endif 21 22 #ifndef FILE_EXIST 23 #define FILE_EXIST 0 24 #endif 25 26 #define DO_NOTHING 27 28 #ifdef WINDOWS_PLATFORM 29 #include <unistd.h> 30 #include <iostream> 31 #define REALPATH(filePath, realPath, ...) (_fullpath(realPath, filePath, ##__VA_ARGS__)) 32 #define MKDIR(filePath) (mkdir(filePath)) 33 #define ACCESS(filePath) (_access(filePath, FILE_EXIST)) 34 #define DISTRIBUTED_DATA_HITRACE(trace) DO_NOTHING 35 36 #elif MAC_PLATFORM 37 #include <stdarg.h> 38 #include <sys/stat.h> 39 #include <unistd.h> 40 #define REALPATH(filePath, realPath, ...) (realpath(filePath, realPath)) 41 #define MKDIR(filePath) (mkdir(filePath, FILE_MODE)) 42 #define ACCESS(filePath) (access(filePath, FILE_EXIST)) 43 #define DISTRIBUTED_DATA_HITRACE(trace) DO_NOTHING 44 45 #else 46 #include <stdarg.h> 47 #include <sys/stat.h> 48 #include <unistd.h> 49 #include <cstdlib> 50 #include "hitrace.h" 51 #define REALPATH(filePath, realPath, ...) (realpath(filePath, realPath)) 52 #define MKDIR(filePath) (mkdir(filePath, FILE_MODE)) 53 #define ACCESS(filePath) (access(filePath, FILE_EXIST)) 54 #define DISTRIBUTED_DATA_HITRACE(trace) HiTrace hitrace(trace) 55 56 #endif 57 58 #ifndef INT_MAX 59 #define INT_MAX 2147483647 60 #endif 61 62 #endif // PREFERENCES_ADAPTOR_H