Store hidelist in magisk database

This commit is contained in:
topjohnwu
2018-11-01 13:23:12 -04:00
parent 3e2afd4b1d
commit 27c688252d
13 changed files with 209 additions and 148 deletions

View File

@@ -4,6 +4,7 @@ include $(CLEAR_VARS)
LOCAL_MODULE:= libutils
LOCAL_C_INCLUDES := jni/include $(LIBUTILS)
LOCAL_SRC_FILES := \
utils.cpp \
file.c \
list.c \
misc.c \

View File

@@ -0,0 +1,6 @@
#pragma once
#include "utils.h"
#include "array.h"
int file_to_array(const char* filename, Array<char *> &arr);

View File

@@ -0,0 +1,25 @@
#include <unistd.h>
#include "utils.hpp"
int file_to_array(const char *filename, Array<char *> &arr) {
if (access(filename, R_OK) != 0)
return 1;
char *line = NULL;
size_t len = 0;
ssize_t read;
FILE *fp = xfopen(filename, "r");
if (fp == NULL)
return 1;
while ((read = getline(&line, &len, fp)) != -1) {
// Remove end newline
if (line[read - 1] == '\n')
line[read - 1] = '\0';
arr.push_back(line);
line = NULL;
}
fclose(fp);
return 0;
}