Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
dadae209
Commit
dadae209
authored
Dec 24, 2022
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unused implementations
parent
4ed34cd6
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
56 deletions
+1
-56
files.cpp
native/src/base/files.cpp
+1
-44
files.hpp
native/src/base/files.hpp
+0
-12
No files found.
native/src/base/files.cpp
View file @
dadae209
...
@@ -382,49 +382,6 @@ void parse_mnt(const char *file, const function<bool(mntent*)> &fn) {
...
@@ -382,49 +382,6 @@ void parse_mnt(const char *file, const function<bool(mntent*)> &fn) {
}
}
}
}
void
backup_folder
(
const
char
*
dir
,
vector
<
raw_file
>
&
files
)
{
char
path
[
PATH_MAX
];
xrealpath
(
dir
,
path
,
sizeof
(
path
));
int
len
=
strlen
(
path
);
pre_order_walk
(
xopen
(
dir
,
O_RDONLY
),
[
&
](
int
dfd
,
dirent
*
entry
)
->
walk_result
{
int
fd
=
xopenat
(
dfd
,
entry
->
d_name
,
O_RDONLY
);
if
(
fd
<
0
)
return
SKIP
;
run_finally
f
([
&
]{
close
(
fd
);
});
if
(
fd_path
(
fd
,
byte_slice
(
path
,
sizeof
(
path
)))
<
0
)
return
SKIP
;
raw_file
file
;
file
.
path
=
path
+
len
+
1
;
if
(
fgetattr
(
fd
,
&
file
.
attr
)
<
0
)
return
SKIP
;
if
(
entry
->
d_type
==
DT_REG
)
{
file
.
content
=
full_read
(
fd
);
}
else
if
(
entry
->
d_type
==
DT_LNK
)
{
xreadlinkat
(
dfd
,
entry
->
d_name
,
path
,
sizeof
(
path
));
file
.
content
=
path
;
}
files
.
emplace_back
(
std
::
move
(
file
));
return
CONTINUE
;
});
}
void
restore_folder
(
const
char
*
dir
,
vector
<
raw_file
>
&
files
)
{
string
base
(
dir
);
// Pre-order means folders will always be first
for
(
raw_file
&
file
:
files
)
{
string
path
=
base
+
"/"
+
file
.
path
;
if
(
S_ISDIR
(
file
.
attr
.
st
.
st_mode
))
{
mkdirs
(
path
.
data
(),
0
);
}
else
if
(
S_ISREG
(
file
.
attr
.
st
.
st_mode
))
{
if
(
auto
fp
=
xopen_file
(
path
.
data
(),
"we"
))
fwrite
(
file
.
content
.
data
(),
1
,
file
.
content
.
size
(),
fp
.
get
());
}
else
if
(
S_ISLNK
(
file
.
attr
.
st
.
st_mode
))
{
symlink
(
file
.
content
.
data
(),
path
.
data
());
}
setattr
(
path
.
data
(),
&
file
.
attr
);
}
}
sDIR
make_dir
(
DIR
*
dp
)
{
sDIR
make_dir
(
DIR
*
dp
)
{
return
sDIR
(
dp
,
[](
DIR
*
dp
){
return
dp
?
closedir
(
dp
)
:
1
;
});
return
sDIR
(
dp
,
[](
DIR
*
dp
){
return
dp
?
closedir
(
dp
)
:
1
;
});
}
}
...
@@ -491,10 +448,10 @@ mmap_data::mmap_data(const char *name, bool rw) {
...
@@ -491,10 +448,10 @@ mmap_data::mmap_data(const char *name, bool rw) {
string
find_apk_path
(
const
char
*
pkg
)
{
string
find_apk_path
(
const
char
*
pkg
)
{
char
buf
[
PATH_MAX
];
char
buf
[
PATH_MAX
];
size_t
len
=
strlen
(
pkg
);
pre_order_walk
(
xopen
(
"/data/app"
,
O_RDONLY
),
[
&
](
int
dfd
,
dirent
*
entry
)
->
walk_result
{
pre_order_walk
(
xopen
(
"/data/app"
,
O_RDONLY
),
[
&
](
int
dfd
,
dirent
*
entry
)
->
walk_result
{
if
(
entry
->
d_type
!=
DT_DIR
)
if
(
entry
->
d_type
!=
DT_DIR
)
return
SKIP
;
return
SKIP
;
size_t
len
=
strlen
(
pkg
);
if
(
strncmp
(
entry
->
d_name
,
pkg
,
len
)
==
0
&&
entry
->
d_name
[
len
]
==
'-'
)
{
if
(
strncmp
(
entry
->
d_name
,
pkg
,
len
)
==
0
&&
entry
->
d_name
[
len
]
==
'-'
)
{
fd_pathat
(
dfd
,
entry
->
d_name
,
buf
,
sizeof
(
buf
));
fd_pathat
(
dfd
,
entry
->
d_name
,
buf
,
sizeof
(
buf
));
return
ABORT
;
return
ABORT
;
...
...
native/src/base/files.hpp
View file @
dadae209
...
@@ -39,16 +39,6 @@ protected:
...
@@ -39,16 +39,6 @@ protected:
void
swap
(
byte_data
&
o
);
void
swap
(
byte_data
&
o
);
};
};
struct
raw_file
{
std
::
string
path
;
file_attr
attr
;
std
::
string
content
;
raw_file
()
:
attr
{}
{}
raw_file
(
const
raw_file
&
)
=
delete
;
raw_file
(
raw_file
&&
o
)
:
path
(
std
::
move
(
o
.
path
)),
attr
(
o
.
attr
),
content
(
std
::
move
(
o
.
content
))
{}
};
struct
mmap_data
:
public
byte_data
{
struct
mmap_data
:
public
byte_data
{
mmap_data
()
=
default
;
mmap_data
()
=
default
;
mmap_data
(
const
mmap_data
&
)
=
delete
;
mmap_data
(
const
mmap_data
&
)
=
delete
;
...
@@ -99,8 +89,6 @@ void parse_prop_file(const char *file,
...
@@ -99,8 +89,6 @@ void parse_prop_file(const char *file,
void
frm_rf
(
int
dirfd
);
void
frm_rf
(
int
dirfd
);
void
clone_dir
(
int
src
,
int
dest
);
void
clone_dir
(
int
src
,
int
dest
);
void
parse_mnt
(
const
char
*
file
,
const
std
::
function
<
bool
(
mntent
*
)
>
&
fn
);
void
parse_mnt
(
const
char
*
file
,
const
std
::
function
<
bool
(
mntent
*
)
>
&
fn
);
void
backup_folder
(
const
char
*
dir
,
std
::
vector
<
raw_file
>
&
files
);
void
restore_folder
(
const
char
*
dir
,
std
::
vector
<
raw_file
>
&
files
);
std
::
string
find_apk_path
(
const
char
*
pkg
);
std
::
string
find_apk_path
(
const
char
*
pkg
);
using
sFILE
=
std
::
unique_ptr
<
FILE
,
decltype
(
&
fclose
)
>
;
using
sFILE
=
std
::
unique_ptr
<
FILE
,
decltype
(
&
fclose
)
>
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment