Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
J
jadx
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
open-source
jadx
Commits
b446bf27
Commit
b446bf27
authored
Mar 26, 2019
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: move filesystem case sensitivity value to JadxArgs
parent
b7109b1b
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
67 additions
and
11 deletions
+67
-11
JadxCLI.java
jadx-cli/src/main/java/jadx/cli/JadxCLI.java
+19
-1
JadxArgs.java
jadx-core/src/main/java/jadx/api/JadxArgs.java
+15
-0
RenameVisitor.java
...e/src/main/java/jadx/core/dex/visitors/RenameVisitor.java
+1
-3
FileUtils.java
jadx-core/src/main/java/jadx/core/utils/files/FileUtils.java
+22
-3
IntegrationTest.java
jadx-core/src/test/java/jadx/tests/api/IntegrationTest.java
+1
-0
JadxWrapper.java
jadx-gui/src/main/java/jadx/gui/JadxWrapper.java
+9
-4
No files found.
jadx-cli/src/main/java/jadx/cli/JadxCLI.java
View file @
b446bf27
package
jadx
.
cli
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
jadx.api.JadxArgs
;
import
jadx.api.JadxDecompiler
;
import
jadx.core.utils.exceptions.JadxArgsValidateException
;
import
jadx.core.utils.files.FileUtils
;
public
class
JadxCLI
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
JadxCLI
.
class
);
...
...
@@ -25,7 +31,9 @@ public class JadxCLI {
}
static
int
processAndSave
(
JadxCLIArgs
inputArgs
)
{
JadxDecompiler
jadx
=
new
JadxDecompiler
(
inputArgs
.
toJadxArgs
());
JadxArgs
args
=
inputArgs
.
toJadxArgs
();
args
.
setFsCaseSensitive
(
getFsCaseSensitivity
(
args
));
JadxDecompiler
jadx
=
new
JadxDecompiler
(
args
);
try
{
jadx
.
load
();
}
catch
(
JadxArgsValidateException
e
)
{
...
...
@@ -42,4 +50,14 @@ public class JadxCLI {
}
return
errorsCount
;
}
private
static
boolean
getFsCaseSensitivity
(
JadxArgs
args
)
{
List
<
File
>
testDirList
=
new
ArrayList
<>(
3
);
testDirList
.
add
(
args
.
getOutDir
());
testDirList
.
add
(
args
.
getOutDirSrc
());
if
(!
args
.
getInputFiles
().
isEmpty
())
{
testDirList
.
add
(
args
.
getInputFiles
().
get
(
0
));
}
return
FileUtils
.
isCaseSensitiveFS
(
testDirList
);
}
}
jadx-core/src/main/java/jadx/api/JadxArgs.java
View file @
b446bf27
...
...
@@ -2,6 +2,7 @@ package jadx.api;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
public
class
JadxArgs
{
...
...
@@ -44,6 +45,8 @@ public class JadxArgs {
private
boolean
respectBytecodeAccModifiers
=
false
;
private
boolean
exportAsGradleProject
=
false
;
private
boolean
isFsCaseSensitive
;
public
JadxArgs
()
{
// use default options
}
...
...
@@ -58,6 +61,10 @@ public class JadxArgs {
return
inputFiles
;
}
public
void
setInputFile
(
File
inputFile
)
{
this
.
inputFiles
=
Collections
.
singletonList
(
inputFile
);
}
public
void
setInputFiles
(
List
<
File
>
inputFiles
)
{
this
.
inputFiles
=
inputFiles
;
}
...
...
@@ -230,6 +237,14 @@ public class JadxArgs {
this
.
exportAsGradleProject
=
exportAsGradleProject
;
}
public
boolean
isFsCaseSensitive
()
{
return
isFsCaseSensitive
;
}
public
void
setFsCaseSensitive
(
boolean
fsCaseSensitive
)
{
isFsCaseSensitive
=
fsCaseSensitive
;
}
@Override
public
String
toString
()
{
final
StringBuilder
sb
=
new
StringBuilder
(
"JadxArgs{"
);
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/RenameVisitor.java
View file @
b446bf27
...
...
@@ -20,7 +20,6 @@ import jadx.core.dex.nodes.DexNode;
import
jadx.core.dex.nodes.FieldNode
;
import
jadx.core.dex.nodes.MethodNode
;
import
jadx.core.dex.nodes.RootNode
;
import
jadx.core.utils.files.FileUtils
;
import
jadx.core.utils.files.InputFile
;
public
class
RenameVisitor
extends
AbstractVisitor
{
...
...
@@ -45,8 +44,7 @@ public class RenameVisitor extends AbstractVisitor {
if
(
deobfuscationOn
)
{
deobfuscator
.
execute
();
}
boolean
isCaseSensitive
=
FileUtils
.
isCaseSensitiveFS
(
new
File
(
inputPath
));
// args.getOutDir() - not set in gui
checkClasses
(
root
,
isCaseSensitive
);
checkClasses
(
root
,
args
.
isFsCaseSensitive
());
}
private
void
checkClasses
(
RootNode
root
,
boolean
caseSensitive
)
{
...
...
jadx-core/src/main/java/jadx/core/utils/files/FileUtils.java
View file @
b446bf27
...
...
@@ -13,6 +13,7 @@ import java.util.ArrayList;
import
java.util.Enumeration
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Optional
;
import
java.util.jar.JarEntry
;
import
java.util.jar.JarOutputStream
;
import
java.util.zip.ZipEntry
;
...
...
@@ -198,8 +199,26 @@ public class FileUtils {
}
}
/**
* Checks dirs in order, fist success result returned
*/
public
static
boolean
isCaseSensitiveFS
(
List
<
File
>
testDirList
)
{
for
(
File
dir
:
testDirList
)
{
Optional
<
Boolean
>
result
=
isCaseSensitiveFSInternal
(
dir
);
if
(
result
.
isPresent
())
{
return
result
.
get
();
}
}
return
IOCase
.
SYSTEM
.
isCaseSensitive
();
}
public
static
boolean
isCaseSensitiveFS
(
File
testDir
)
{
if
(
testDir
!=
null
)
{
Optional
<
Boolean
>
result
=
isCaseSensitiveFSInternal
(
testDir
);
return
result
.
orElseGet
(
IOCase
.
SYSTEM
::
isCaseSensitive
);
}
private
static
Optional
<
Boolean
>
isCaseSensitiveFSInternal
(
@Nullable
File
testDir
)
{
if
(
testDir
!=
null
&&
testDir
.
exists
()
&&
testDir
.
isDirectory
())
{
File
caseCheckUpper
=
new
File
(
testDir
,
"CaseCheck"
);
File
caseCheckLow
=
new
File
(
testDir
,
"casecheck"
);
try
{
...
...
@@ -208,7 +227,7 @@ public class FileUtils {
boolean
caseSensitive
=
!
caseCheckLow
.
exists
();
LOG
.
debug
(
"Filesystem at {} is {}case-sensitive"
,
testDir
.
getAbsolutePath
(),
(
caseSensitive
?
""
:
"NOT "
));
return
caseSensitive
;
return
Optional
.
of
(
caseSensitive
)
;
}
else
{
LOG
.
debug
(
"Failed to create file: {}"
,
caseCheckUpper
.
getAbsolutePath
());
}
...
...
@@ -223,7 +242,7 @@ public class FileUtils {
}
}
}
return
IOCase
.
SYSTEM
.
isCaseSensitive
();
return
Optional
.
empty
();
}
public
static
File
toFile
(
String
path
)
{
...
...
jadx-core/src/test/java/jadx/tests/api/IntegrationTest.java
View file @
b446bf27
...
...
@@ -78,6 +78,7 @@ public abstract class IntegrationTest extends TestUtils {
args
.
setShowInconsistentCode
(
true
);
args
.
setThreadsCount
(
1
);
args
.
setSkipResources
(
true
);
args
.
setFsCaseSensitive
(
false
);
// use same value on all systems
}
public
ClassNode
getClassNode
(
Class
<?>
clazz
)
{
...
...
jadx-gui/src/main/java/jadx/gui/JadxWrapper.java
View file @
b446bf27
package
jadx
.
gui
;
import
javax.swing.*
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
...
...
@@ -8,8 +9,6 @@ import java.util.List;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.stream.Collectors
;
import
javax.swing.ProgressMonitor
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -18,6 +17,7 @@ import jadx.api.JadxDecompiler;
import
jadx.api.JavaClass
;
import
jadx.api.JavaPackage
;
import
jadx.api.ResourceFile
;
import
jadx.core.utils.files.FileUtils
;
import
jadx.gui.settings.JadxSettings
;
public
class
JadxWrapper
{
...
...
@@ -34,8 +34,12 @@ public class JadxWrapper {
public
void
openFile
(
File
file
)
{
this
.
openFile
=
file
;
try
{
this
.
decompiler
=
new
JadxDecompiler
(
settings
.
toJadxArgs
());
this
.
decompiler
.
getArgs
().
setInputFiles
(
Collections
.
singletonList
(
file
));
JadxArgs
jadxArgs
=
settings
.
toJadxArgs
();
jadxArgs
.
setInputFile
(
file
);
// output folder not known yet => use input dir as a best choice
jadxArgs
.
setFsCaseSensitive
(
FileUtils
.
isCaseSensitiveFS
(
file
.
getParentFile
()));
this
.
decompiler
=
new
JadxDecompiler
(
jadxArgs
);
this
.
decompiler
.
load
();
}
catch
(
Exception
e
)
{
LOG
.
error
(
"Jadx init error"
,
e
);
...
...
@@ -97,6 +101,7 @@ public class JadxWrapper {
}).
collect
(
Collectors
.
toList
());
}
// TODO: move to CLI and filter classes in JadxDecompiler
public
List
<
String
>
getExcludedPackages
()
{
String
excludedPackages
=
settings
.
getExcludedPackages
().
trim
();
if
(
excludedPackages
.
isEmpty
())
{
...
...
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