• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 The Android Open Source Project
2 //
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 #pragma once
15 
16 #ifdef _MSC_VER
17   #include "aemu/base/msvc.h"
18 #endif
19 
20 #include <stdio.h>
21 #include <sys/stat.h>
22 #include <sys/types.h>
23 
24 FILE* android_fopen(const char* path, const char* mode);
25 FILE* android_popen(const char* path, const char* mode);
26 
27 // This thing uses macro varargs to select which open function to use.
28 // Because __VA_ARGS__ consumes a different amount of arguments the call_name
29 // will have a different name depending on how many arguments are passed
30 #define DETERMINE_OPEN_CALL(first, second, third, call_name, ...) call_name
31 #define android_open(...) DETERMINE_OPEN_CALL(__VA_ARGS__, \
32                                               android_open_with_mode, \
33                                               android_open_without_mode) \
34                                                   (__VA_ARGS__)
35 
36 // WARNING: Do not use these, just use the android_open macro above the way
37 // you would use open. The version to use gets picked automatically
38 int android_open_without_mode(const char* path, int flags);
39 int android_open_with_mode(const char* path, int flags, mode_t mode);
40 
41 #ifdef _WIN32
42   #define android_lstat(path, buf) android_stat((path), (buf))
43   int android_stat(const char* path, struct _stati64* buf);
44 #else
45 int android_stat(const char* path, struct stat* buf);
46 int android_lstat(const char* path, struct stat* buf);
47 #endif
48 
49 int android_access(const char* path, int mode);
50 int android_mkdir(const char* path, mode_t mode);
51 
52 int android_creat(const char* path, mode_t mode);
53 
54 int android_unlink(const char* path);
55 int android_chmod(const char* path, mode_t mode);
56 
57 int android_rmdir(const char* path);
58