forked from libretro/RetroArch
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathvfs_implementation_saf.h
More file actions
110 lines (88 loc) · 4.47 KB
/
vfs_implementation_saf.h
File metadata and controls
110 lines (88 loc) · 4.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/* Copyright (C) 2010-2020 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (vfs_implementation_saf.h).
* ---------------------------------------------------------------------------------------
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __LIBRETRO_SDK_VFS_IMPLEMENTATION_SAF_H
#define __LIBRETRO_SDK_VFS_IMPLEMENTATION_SAF_H
#include <stdio.h>
#include <stdint.h>
#include <jni.h>
#include <libretro.h>
#include <retro_environment.h>
#include <vfs/vfs.h>
#include <vfs/vfs_implementation.h>
RETRO_BEGIN_DECLS
typedef struct libretro_vfs_implementation_saf_dir
{
jobject directory_object;
jstring dirent_name_object;
const char *dirent_name;
bool dirent_is_dir;
} libretro_vfs_implementation_saf_dir;
struct libretro_vfs_implementation_saf_path_split_result
{
char *tree;
char *path;
};
/*
* Initialize this VFS backend. This must be called prior to using any of the VFS operations provided by this backend.
* get_jni_env should be a function that returns the JNIEnv for the current thread.
* activity_object should be the current Android android.app.Activity.
*/
bool retro_vfs_init_saf(JNIEnv *(*get_jni_env)(void), jobject activity_object);
/*
* Deinitialize this VFS backend.
*/
bool retro_vfs_deinit_saf(void);
/*
* Split a serialized "saf://" path string into tree and path components for use with this backend.
* Returns true if successful or false if not.
* The results will be returned in `out` and must be freed by the caller.
*/
bool retro_vfs_path_split_saf(struct libretro_vfs_implementation_saf_path_split_result *out, const char *serialized_path);
/*
* Join the tree and path components into a single serialized "saf://" path string.
* Returns the serialized path if successful or NULL if not.
* The returned path must be freed by the caller.
*/
char *retro_vfs_path_join_saf(const char *tree, const char *path);
/*
* Split a "content://" document URI returned by the Android Storage Access Framework into tree and path components for use with this backend.
* Returns true if successful or false if not.
* The results will be returned in `out` and must be freed by the caller.
*/
bool retro_vfs_path_split_content_saf(struct libretro_vfs_implementation_saf_path_split_result *out, const char *content_uri);
/*
* Open a file, returning its file descriptor if successful or -1 if not.
* The file descriptor can be operated on using the POSIX file system API (`read()`, `write()`, `lseek()`, `close()`, etc).
* You can also turn the file descriptor into a `FILE *` by calling `fdopen()` on it.
*/
int retro_vfs_file_open_saf(const char *tree, const char *path, unsigned mode);
int retro_vfs_file_remove_saf(const char *tree, const char *path);
int retro_vfs_file_rename_saf(const char *old_tree, const char *old_path, const char *new_tree, const char *new_path);
int retro_vfs_stat_saf(const char *tree, const char *path, int64_t *size);
int retro_vfs_mkdir_saf(const char *tree, const char *dir);
libretro_vfs_implementation_saf_dir *retro_vfs_opendir_saf(const char *tree, const char *dir, bool include_hidden);
bool retro_vfs_readdir_saf(libretro_vfs_implementation_saf_dir *dirstream);
const char *retro_vfs_dirent_get_name_saf(libretro_vfs_implementation_saf_dir *dirstream);
bool retro_vfs_dirent_is_dir_saf(libretro_vfs_implementation_saf_dir *dirstream);
int retro_vfs_closedir_saf(libretro_vfs_implementation_saf_dir *dirstream);
RETRO_END_DECLS
#endif