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
f53fc03c
Commit
f53fc03c
authored
Jan 15, 2018
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: use dynamic check for filesystem case-sensitivity (#158)
parent
9278c510
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
25 deletions
+61
-25
build.gradle
jadx-core/build.gradle
+1
-1
RenameVisitor.java
...e/src/main/java/jadx/core/dex/visitors/RenameVisitor.java
+13
-14
ExportGradleProject.java
...e/src/main/java/jadx/core/export/ExportGradleProject.java
+2
-2
FileUtils.java
jadx-core/src/main/java/jadx/core/utils/files/FileUtils.java
+45
-8
No files found.
jadx-core/build.gradle
View file @
f53fc03c
...
...
@@ -4,7 +4,7 @@ dependencies {
runtime
files
(
jadxClasspath
)
compile
files
(
'lib/dx-1.13.jar'
)
compile
'commons-io:commons-io:2.
4
'
compile
'commons-io:commons-io:2.
6
'
compile
'org.ow2.asm:asm:5.0.3'
compile
'com.intellij:annotations:12.0'
compile
'uk.com.robust-it:cloning:1.9.2'
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/RenameVisitor.java
View file @
f53fc03c
package
jadx
.
core
.
dex
.
visitors
;
import
java.io.File
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
org.apache.commons.io.FilenameUtils
;
import
jadx.api.IJadxArgs
;
import
jadx.core.Consts
;
import
jadx.core.codegen.TypeGen
;
...
...
@@ -15,20 +22,11 @@ import jadx.core.dex.nodes.FieldNode;
import
jadx.core.dex.nodes.MethodNode
;
import
jadx.core.dex.nodes.RootNode
;
import
jadx.core.utils.exceptions.JadxException
;
import
jadx.core.utils.files.FileUtils
;
import
jadx.core.utils.files.InputFile
;
import
java.io.File
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
org.apache.commons.io.FilenameUtils
;
import
org.apache.commons.io.IOCase
;
public
class
RenameVisitor
extends
AbstractVisitor
{
private
static
final
boolean
CASE_SENSITIVE_FS
=
IOCase
.
SYSTEM
.
isCaseSensitive
();
private
Deobfuscator
deobfuscator
;
@Override
...
...
@@ -36,7 +34,7 @@ public class RenameVisitor extends AbstractVisitor {
IJadxArgs
args
=
root
.
getArgs
();
List
<
DexNode
>
dexNodes
=
root
.
getDexNodes
();
if
(
dexNodes
.
size
()
==
0
)
{
if
(
dexNodes
.
isEmpty
()
)
{
return
;
}
InputFile
firstInputFile
=
dexNodes
.
get
(
0
).
getDexFile
().
getInputFile
();
...
...
@@ -50,7 +48,8 @@ public class RenameVisitor extends AbstractVisitor {
if
(
deobfuscationOn
)
{
deobfuscator
.
execute
();
}
checkClasses
(
root
);
boolean
isCaseSensitive
=
FileUtils
.
isCaseSensitiveFS
(
new
File
(
inputPath
));
// args.getOutDir() - not set in gui
checkClasses
(
root
,
isCaseSensitive
);
}
@Override
...
...
@@ -63,11 +62,11 @@ public class RenameVisitor extends AbstractVisitor {
return
false
;
}
private
void
checkClasses
(
RootNode
root
)
{
private
void
checkClasses
(
RootNode
root
,
boolean
caseSensitive
)
{
Set
<
String
>
clsNames
=
new
HashSet
<>();
for
(
ClassNode
cls
:
root
.
getClasses
(
true
))
{
checkClassName
(
cls
);
if
(!
CASE_SENSITIVE_FS
)
{
if
(!
caseSensitive
)
{
ClassInfo
classInfo
=
cls
.
getClassInfo
();
String
clsFileName
=
classInfo
.
getAlias
().
getFullPath
();
if
(!
clsNames
.
add
(
clsFileName
.
toLowerCase
()))
{
...
...
jadx-core/src/main/java/jadx/core/export/ExportGradleProject.java
View file @
f53fc03c
...
...
@@ -40,8 +40,8 @@ public class ExportGradleProject {
public
void
init
()
{
try
{
FileUtils
.
makeDirs
ForFile
(
srcOutDir
);
FileUtils
.
makeDirs
ForFile
(
resOutDir
);
FileUtils
.
makeDirs
(
srcOutDir
);
FileUtils
.
makeDirs
(
resOutDir
);
saveBuildGradle
();
skipGeneratedClasses
();
}
catch
(
Exception
e
)
{
...
...
jadx-core/src/main/java/jadx/core/utils/files/FileUtils.java
View file @
f53fc03c
package
jadx
.
core
.
utils
.
files
;
import
jadx.core.utils.exceptions.JadxRuntimeException
;
import
java.io.BufferedInputStream
;
import
java.io.Closeable
;
import
java.io.File
;
...
...
@@ -18,10 +16,14 @@ import java.util.jar.JarOutputStream;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipFile
;
import
org.apache.commons.io.IOCase
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
jadx.core.utils.exceptions.JadxRuntimeException
;
public
class
FileUtils
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
FileUtils
.
class
);
...
...
@@ -43,12 +45,19 @@ public class FileUtils {
}
public
static
void
makeDirsForFile
(
File
file
)
{
File
dir
=
file
.
getParentFile
();
if
(
dir
!=
null
&&
!
dir
.
exists
())
{
// if directory already created in other thread mkdirs will return false,
// so check dir existence again
if
(!
dir
.
mkdirs
()
&&
!
dir
.
exists
())
{
throw
new
JadxRuntimeException
(
"Can't create directory "
+
dir
);
if
(
file
!=
null
)
{
makeDirs
(
file
.
getParentFile
());
}
}
private
static
final
Object
MKDIR_SYNC
=
new
Object
();
public
static
void
makeDirs
(
@Nullable
File
dir
)
{
if
(
dir
!=
null
)
{
synchronized
(
MKDIR_SYNC
)
{
if
(!
dir
.
exists
()
&&
!
dir
.
mkdirs
())
{
throw
new
JadxRuntimeException
(
"Can't create directory "
+
dir
);
}
}
}
}
...
...
@@ -186,4 +195,32 @@ public class FileUtils {
}
}
}
public
static
boolean
isCaseSensitiveFS
(
File
testDir
)
{
if
(
testDir
!=
null
)
{
File
caseCheckUpper
=
new
File
(
testDir
,
"CaseCheck"
);
File
caseCheckLow
=
new
File
(
testDir
,
"casecheck"
);
try
{
makeDirs
(
testDir
);
if
(
caseCheckUpper
.
createNewFile
())
{
boolean
caseSensitive
=
!
caseCheckLow
.
exists
();
LOG
.
debug
(
"Filesystem at {} is {} case-sensitive"
,
testDir
.
getAbsolutePath
(),
(
caseSensitive
?
""
:
"NOT"
));
return
caseSensitive
;
}
else
{
LOG
.
debug
(
"Failed to create file: {}"
,
caseCheckUpper
.
getAbsolutePath
());
}
}
catch
(
Exception
e
)
{
LOG
.
debug
(
"Failed to detect filesystem case-sensitivity by file creation"
,
e
);
}
finally
{
try
{
caseCheckUpper
.
delete
();
caseCheckLow
.
delete
();
}
catch
(
Exception
e
)
{
// ignore
}
}
}
return
IOCase
.
SYSTEM
.
isCaseSensitive
();
}
}
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