Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Sleuthkit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IRT
Sleuthkit
Commits
5b102887
Commit
5b102887
authored
4 years ago
by
apriestman
Browse files
Options
Downloads
Patches
Plain Diff
Use parent folder ID for findFiles instead of the path
parent
c296c766
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java
+51
-6
51 additions, 6 deletions
bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java
with
51 additions
and
6 deletions
bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java
+
51
−
6
View file @
5b102887
...
@@ -5434,7 +5434,7 @@ List<Content> getAbstractFileChildren(Content parent, TSK_DB_FILES_TYPE_ENUM typ
...
@@ -5434,7 +5434,7 @@ List<Content> getAbstractFileChildren(Content parent, TSK_DB_FILES_TYPE_ENUM typ
releaseSingleUserCaseReadLock();
releaseSingleUserCaseReadLock();
}
}
}
}
/**
/**
* Returns the list of all AbstractFile Children for a given
* Returns the list of all AbstractFile Children for a given
* AbstractFileParent
* AbstractFileParent
...
@@ -8395,10 +8395,8 @@ private void updateFilePath(CaseDbConnection connection, long objId, String path
...
@@ -8395,10 +8395,8 @@ private void updateFilePath(CaseDbConnection connection, long objId, String path
}
}
/**
/**
* Find all files
in the data source,
by name and parent
* Find all files by name and parent
*
*
* @param dataSource the dataSource (Image, parent-less VirtualDirectory) to
* search for the given file name
* @param fileName Pattern of the name of the file or directory to match
* @param fileName Pattern of the name of the file or directory to match
* (case insensitive, used in LIKE SQL statement).
* (case insensitive, used in LIKE SQL statement).
* @param parentFile Object for parent file/directory to find children in
* @param parentFile Object for parent file/directory to find children in
...
@@ -8409,8 +8407,27 @@ private void updateFilePath(CaseDbConnection connection, long objId, String path
...
@@ -8409,8 +8407,27 @@ private void updateFilePath(CaseDbConnection connection, long objId, String path
*
*
* @throws org.sleuthkit.datamodel.TskCoreException
* @throws org.sleuthkit.datamodel.TskCoreException
*/
*/
public List<AbstractFile> findFiles(Content dataSource, String fileName, AbstractFile parentFile) throws TskCoreException {
public List<AbstractFile> findFilesInFolder(String fileName, AbstractFile parentFile) throws TskCoreException {
return findFiles(dataSource, fileName, parentFile.getName());
CaseDbConnection connection = null;
ResultSet rs = null;
acquireSingleUserCaseReadLock();
try {
connection = connections.getConnection();
PreparedStatement statement = connection.getPreparedStatement(PREPARED_STATEMENT.SELECT_FILES_BY_PARENT_AND_NAME);
statement.clearParameters();
long parentId = parentFile.getId();
statement.setLong(1, parentId);
statement.setString(2, fileName);
rs = connection.executeQuery(statement);
return resultSetToAbstractFiles(rs, connection);
} catch (SQLException ex) {
throw new TskCoreException("Error getting AbstractFile children with name=" + fileName + " for Content parent with ID=" + parentFile.getId(), ex);
} finally {
closeResultSet(rs);
closeConnection(connection);
releaseSingleUserCaseReadLock();
}
}
}
/**
/**
...
@@ -12433,6 +12450,12 @@ private enum PREPARED_STATEMENT {
...
@@ -12433,6 +12450,12 @@ private enum PREPARED_STATEMENT {
+ "ON tsk_objects.obj_id=tsk_files.obj_id " //NON-NLS
+ "ON tsk_objects.obj_id=tsk_files.obj_id " //NON-NLS
+ "WHERE (tsk_objects.par_obj_id = ? AND tsk_files.type = ? ) " //NON-NLS
+ "WHERE (tsk_objects.par_obj_id = ? AND tsk_files.type = ? ) " //NON-NLS
+ "ORDER BY tsk_files.dir_type, LOWER(tsk_files.name)"), //NON-NLS
+ "ORDER BY tsk_files.dir_type, LOWER(tsk_files.name)"), //NON-NLS
SELECT_FILES_BY_PARENT_AND_NAME("SELECT tsk_files.* " //NON-NLS
+ "FROM tsk_objects INNER JOIN tsk_files " //NON-NLS
+ "ON tsk_objects.obj_id=tsk_files.obj_id " //NON-NLS
+ "WHERE (tsk_objects.par_obj_id = ? AND " //NON-NLS
+ "LOWER(tsk_files.name) LIKE LOWER(?) AND LOWER(tsk_files.name) NOT LIKE LOWER('%journal%')) "//NON-NLS
+ "ORDER BY tsk_files.dir_type, LOWER(tsk_files.name)"), //NON-NLS
SELECT_FILE_IDS_BY_PARENT("SELECT tsk_files.obj_id AS obj_id " //NON-NLS
SELECT_FILE_IDS_BY_PARENT("SELECT tsk_files.obj_id AS obj_id " //NON-NLS
+ "FROM tsk_objects INNER JOIN tsk_files " //NON-NLS
+ "FROM tsk_objects INNER JOIN tsk_files " //NON-NLS
+ "ON tsk_objects.obj_id=tsk_files.obj_id " //NON-NLS
+ "ON tsk_objects.obj_id=tsk_files.obj_id " //NON-NLS
...
@@ -14225,6 +14248,28 @@ public Collection<FileSystem> getFileSystems(Image image) {
...
@@ -14225,6 +14248,28 @@ public Collection<FileSystem> getFileSystems(Image image) {
return new ArrayList<>();
return new ArrayList<>();
}
}
}
}
/**
* Find all files in the data source, by name and parent
*
* @param dataSource the dataSource (Image, parent-less VirtualDirectory) to
* search for the given file name
* @param fileName Pattern of the name of the file or directory to match
* (case insensitive, used in LIKE SQL statement).
* @param parentFile Object for parent file/directory to find children in
*
* @return a list of AbstractFile for files/directories whose name matches
* fileName and that were inside a directory described by
* parentFile.
*
* @throws org.sleuthkit.datamodel.TskCoreException
*
* @deprecated Use findFilesInFolder()
*/
@Deprecated
public List<AbstractFile> findFiles(Content dataSource, String fileName, AbstractFile parentFile) throws TskCoreException {
return findFilesInFolder(fileName, parentFile);
}
/**
/**
* Acquires a write lock, but only if this is a single-user case. Always
* Acquires a write lock, but only if this is a single-user case. Always
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment