2020-07-06 09:02:01 -06:00
|
|
|
// Copyright 2018 Dolphin Emulator Project
|
2021-07-04 19:22:19 -06:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2020-07-06 09:02:01 -06:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2020-11-04 12:59:39 -07:00
|
|
|
#include <ios>
|
2020-07-06 09:02:01 -06:00
|
|
|
#include <string>
|
2023-01-30 11:24:53 -07:00
|
|
|
#include <string_view>
|
2020-11-08 08:57:49 -07:00
|
|
|
#include <vector>
|
2020-07-06 09:02:01 -06:00
|
|
|
|
|
|
|
#include <jni.h>
|
|
|
|
|
|
|
|
std::string GetJString(JNIEnv* env, jstring jstr);
|
2023-01-30 11:24:53 -07:00
|
|
|
jstring ToJString(JNIEnv* env, std::string_view str);
|
2021-05-20 08:34:30 -06:00
|
|
|
|
2020-07-06 09:02:01 -06:00
|
|
|
std::vector<std::string> JStringArrayToVector(JNIEnv* env, jobjectArray array);
|
2022-12-27 14:28:06 -07:00
|
|
|
jobjectArray VectorToJStringArray(JNIEnv* env, const std::vector<std::string>& vector);
|
|
|
|
|
|
|
|
template <typename T, typename F>
|
|
|
|
jobjectArray VectorToJObjectArray(JNIEnv* env, const std::vector<T>& vector, jclass clazz, F f)
|
|
|
|
{
|
|
|
|
jobjectArray result = env->NewObjectArray(vector.size(), clazz, nullptr);
|
|
|
|
for (jsize i = 0; i < vector.size(); ++i)
|
|
|
|
{
|
|
|
|
jobject obj = f(env, vector[i]);
|
|
|
|
env->SetObjectArrayElement(result, i, obj);
|
|
|
|
env->DeleteLocalRef(obj);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2020-06-26 09:52:31 -06:00
|
|
|
|
2020-11-04 12:59:39 -07:00
|
|
|
// Returns true if the given path should be opened as Android content instead of a normal file.
|
2023-01-30 11:24:53 -07:00
|
|
|
bool IsPathAndroidContent(std::string_view uri);
|
2020-11-04 12:59:39 -07:00
|
|
|
|
|
|
|
// Turns a C/C++ style mode (e.g. "rb") into one which can be used with OpenAndroidContent.
|
|
|
|
std::string OpenModeToAndroid(std::string mode);
|
2020-11-04 12:59:39 -07:00
|
|
|
std::string OpenModeToAndroid(std::ios_base::openmode mode);
|
2020-11-04 12:59:39 -07:00
|
|
|
|
|
|
|
// Opens a given file and returns a file descriptor.
|
2023-01-30 11:24:53 -07:00
|
|
|
int OpenAndroidContent(std::string_view uri, std::string_view mode);
|
2020-11-04 12:59:39 -07:00
|
|
|
|
|
|
|
// Deletes a given file.
|
2023-01-30 11:24:53 -07:00
|
|
|
bool DeleteAndroidContent(std::string_view uri);
|
2020-11-05 11:47:23 -07:00
|
|
|
// Returns -1 if not found, -2 if directory, file size otherwise.
|
2023-01-30 11:24:53 -07:00
|
|
|
jlong GetAndroidContentSizeAndIsDirectory(std::string_view uri);
|
2020-11-05 11:47:23 -07:00
|
|
|
|
2020-11-08 07:39:17 -07:00
|
|
|
// An unmangled URI (one which the C++ code has not appended anything to) can't be relied on
|
|
|
|
// to contain a file name at all. If a file name is desired, this function is the most reliable
|
|
|
|
// way to get it, but the display name is not guaranteed to always actually be like a file name.
|
|
|
|
// An empty string will be returned for files which do not exist.
|
2023-01-30 11:24:53 -07:00
|
|
|
std::string GetAndroidContentDisplayName(std::string_view uri);
|
2020-11-08 07:39:17 -07:00
|
|
|
|
2020-11-08 15:01:59 -07:00
|
|
|
// Returns the display names of all children of a directory, non-recursively.
|
2023-01-30 11:24:53 -07:00
|
|
|
std::vector<std::string> GetAndroidContentChildNames(std::string_view uri);
|
2020-11-08 08:57:49 -07:00
|
|
|
|
2023-01-30 11:24:53 -07:00
|
|
|
std::vector<std::string> DoFileSearchAndroidContent(std::string_view directory,
|
2020-12-28 05:25:24 -07:00
|
|
|
const std::vector<std::string>& extensions,
|
|
|
|
bool recursive);
|
|
|
|
|
2020-10-01 02:10:34 -06:00
|
|
|
int GetNetworkIpAddress();
|
|
|
|
int GetNetworkPrefixLength();
|
|
|
|
int GetNetworkGateway();
|