-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
190 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,24 @@ | ||
# file-walker | ||
File list and search in the XProc style | ||
File list and search in the XProc style. | ||
```` | ||
import module namespace fw="quodatum.file.walker"; | ||
declare namespace c="http://www.w3.org/ns/xproc-step"; | ||
fw:directory-list($test:dir,map{"depth":-1}) | ||
```` | ||
see https://www.w3.org/TR/xproc/#c.directory-list | ||
|
||
Also testing the performance of the built-in file module against | ||
a Java SimpleFileVisitor implementation. | ||
https://docs.oracle.com/javase/7/docs/api/java/nio/file/FileVisitResult.html | ||
|
||
## Performance | ||
|
||
```` | ||
<testsuites time="PT9M22.656S"> | ||
<testsuite name="file:///C:/Users/andy/git/file-walker/src/test/test.xqm" time="PT9M22.654S" tests="2" failures="0" errors="0" skipped="0"> | ||
<testcase name="directory-list" time="PT5M36.935S"/> | ||
<testcase name="directory-list-xq" time="PT3M45.697S"/> | ||
</testsuite> | ||
</testsuites> | ||
```` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="WINDOWS-1252" standalone="no"?> | ||
<jardesc> | ||
<jar path="file-walker/src/main/content/quodatum-files-0.1.5.jar"/> | ||
<options buildIfNeeded="true" compress="true" descriptionLocation="/file-walker/makjar.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="true" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/> | ||
<storedRefactorings deprecationInfo="true" structuralOnly="false"/> | ||
<selectedProjects/> | ||
<manifest generateManifest="true" manifestLocation="" manifestVersion="1.0" reuseManifest="false" saveManifest="false" usesManifest="true"> | ||
<sealing sealJar="false"> | ||
<packagesToSeal/> | ||
<packagesToUnSeal/> | ||
</sealing> | ||
</manifest> | ||
<selectedElements exportClassFiles="true" exportJavaFiles="true" exportOutputFolder="false"> | ||
<javaElement handleIdentifier="=file-walker/src\/java"/> | ||
</selectedElements> | ||
</jardesc> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,24 @@ | ||
package com.quodatum.file; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.FileVisitOption; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.EnumSet; | ||
|
||
import com.quodatum.file.Walker; | ||
|
||
import org.basex.query.value.Value; | ||
import org.basex.query.value.map.Map; | ||
|
||
public class Runner { | ||
public static Value filewalk(final String path) throws IOException { | ||
Path startingDir = Paths.get(path); | ||
Walker pf = new Walker(); | ||
Files.walkFileTree(startingDir, pf); | ||
return pf.result(); | ||
public static Value filewalk(final String path,final Map options ) throws IOException { | ||
Path startingDir = Paths.get(path); | ||
System.out.print(options); | ||
EnumSet<FileVisitOption> opts = EnumSet.of(FileVisitOption.FOLLOW_LINKS); | ||
Walker walk = new Walker(startingDir); | ||
Files.walkFileTree(startingDir,opts, Integer.MAX_VALUE, walk); | ||
return walk.result(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<package xmlns="http://www.basex.org/modules/pkg"> | ||
<jar>quodatum-files-0.1.4.jar</jar> | ||
<jar>quodatum-files-0.1.7.jar</jar> | ||
<class>com.quodatum.file.Runner</class> | ||
</package> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
import module namespace fw="quodatum.file.walker"; | ||
declare namespace c="http://www.w3.org/ns/xproc-step"; | ||
(: fw:web-resolve("")=> fw:directory-list-xq() :) | ||
let $r:=fw:web-resolve("")=> fw:directory-list(map{"depth":-1}) | ||
return $r | ||
declare variable $large:="Z:\pictures\Pictures"; | ||
declare variable $small:="Z:\recordings\radio"; | ||
declare variable $local:="C:\Users\andy\Desktop\radio"; | ||
|
||
let $r:= fw:directory-list($small,map{"depth":-1}) | ||
return $r | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module namespace test = 'http://basex.org/modules/xqunit-tests'; | ||
(:~ | ||
: unit tests for filewalker module | ||
:) | ||
import module namespace fw="quodatum.file.walker"; | ||
declare namespace c="http://www.w3.org/ns/xproc-step"; | ||
declare variable $test:dir:="\\ODROID-JESSIE\sda1\pictures\Pictures"; | ||
|
||
|
||
(:~ directory-list :) | ||
declare | ||
%unit:test | ||
function test:directory-list() { | ||
let $r:=fw:directory-list($test:dir,map{"depth":-1}) | ||
let $_:=trace($r//c:file=>count(),"files: ") | ||
return unit:assert($r) | ||
}; | ||
|
||
declare | ||
%unit:test | ||
function test:directory-list-xq() { | ||
let $r:=fw:directory-list-xq($test:dir,map{"depth":-1}) | ||
let $_:=trace($r//c:file=>count(),"files: ") | ||
return unit:assert($r) | ||
}; |