Merge branch 'main' of https://git.rsems.dev/Schroeder/treesize
resolved conflicts between new and old repo
This commit is contained in:
7
.classpath
Executable file
7
.classpath
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="con" path="org.scala-ide.sdt.launching.SCALA_CONTAINER"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk11"/>
|
||||||
|
<classpathentry kind="output" path="bin"/>
|
||||||
|
</classpath>
|
||||||
0
.gitignore
vendored
Normal file
0
.gitignore
vendored
Normal file
179
.idea/codeStyles/Project.xml
generated
Normal file
179
.idea/codeStyles/Project.xml
generated
Normal file
@@ -0,0 +1,179 @@
|
|||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<code_scheme name="Project" version="173">
|
||||||
|
<option name="OTHER_INDENT_OPTIONS">
|
||||||
|
<value>
|
||||||
|
<option name="INDENT_SIZE" value="2" />
|
||||||
|
<option name="TAB_SIZE" value="2" />
|
||||||
|
<option name="USE_TAB_CHARACTER" value="true" />
|
||||||
|
<option name="SMART_TABS" value="true" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<JetCodeStyleSettings>
|
||||||
|
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||||
|
</JetCodeStyleSettings>
|
||||||
|
<ScalaCodeStyleSettings>
|
||||||
|
<option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
|
||||||
|
</ScalaCodeStyleSettings>
|
||||||
|
<codeStyleSettings language="CSS">
|
||||||
|
<indentOptions>
|
||||||
|
<option name="INDENT_SIZE" value="2" />
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||||
|
<option name="TAB_SIZE" value="2" />
|
||||||
|
<option name="USE_TAB_CHARACTER" value="true" />
|
||||||
|
<option name="SMART_TABS" value="true" />
|
||||||
|
</indentOptions>
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="GSP">
|
||||||
|
<indentOptions>
|
||||||
|
<option name="INDENT_SIZE" value="2" />
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||||
|
<option name="TAB_SIZE" value="2" />
|
||||||
|
<option name="USE_TAB_CHARACTER" value="true" />
|
||||||
|
<option name="SMART_TABS" value="true" />
|
||||||
|
</indentOptions>
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="Gherkin">
|
||||||
|
<indentOptions>
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||||
|
<option name="TAB_SIZE" value="2" />
|
||||||
|
<option name="USE_TAB_CHARACTER" value="true" />
|
||||||
|
</indentOptions>
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="Groovy">
|
||||||
|
<indentOptions>
|
||||||
|
<option name="INDENT_SIZE" value="2" />
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||||
|
<option name="TAB_SIZE" value="2" />
|
||||||
|
<option name="USE_TAB_CHARACTER" value="true" />
|
||||||
|
<option name="SMART_TABS" value="true" />
|
||||||
|
</indentOptions>
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="HTML">
|
||||||
|
<indentOptions>
|
||||||
|
<option name="INDENT_SIZE" value="2" />
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||||
|
<option name="TAB_SIZE" value="2" />
|
||||||
|
<option name="USE_TAB_CHARACTER" value="true" />
|
||||||
|
<option name="SMART_TABS" value="true" />
|
||||||
|
</indentOptions>
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="JAVA">
|
||||||
|
<option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
|
||||||
|
<option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
|
||||||
|
<option name="KEEP_BLANK_LINES_BETWEEN_PACKAGE_DECLARATION_AND_HEADER" value="1" />
|
||||||
|
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" />
|
||||||
|
<indentOptions>
|
||||||
|
<option name="INDENT_SIZE" value="2" />
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||||
|
<option name="TAB_SIZE" value="2" />
|
||||||
|
<option name="USE_TAB_CHARACTER" value="true" />
|
||||||
|
<option name="SMART_TABS" value="true" />
|
||||||
|
</indentOptions>
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="JSON">
|
||||||
|
<indentOptions>
|
||||||
|
<option name="TAB_SIZE" value="2" />
|
||||||
|
<option name="USE_TAB_CHARACTER" value="true" />
|
||||||
|
</indentOptions>
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="JSP">
|
||||||
|
<indentOptions>
|
||||||
|
<option name="INDENT_SIZE" value="2" />
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||||
|
<option name="TAB_SIZE" value="2" />
|
||||||
|
<option name="USE_TAB_CHARACTER" value="true" />
|
||||||
|
<option name="SMART_TABS" value="true" />
|
||||||
|
</indentOptions>
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="JSPX">
|
||||||
|
<indentOptions>
|
||||||
|
<option name="INDENT_SIZE" value="2" />
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||||
|
<option name="TAB_SIZE" value="2" />
|
||||||
|
<option name="USE_TAB_CHARACTER" value="true" />
|
||||||
|
<option name="SMART_TABS" value="true" />
|
||||||
|
</indentOptions>
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="JavaScript">
|
||||||
|
<indentOptions>
|
||||||
|
<option name="INDENT_SIZE" value="2" />
|
||||||
|
<option name="TAB_SIZE" value="2" />
|
||||||
|
<option name="USE_TAB_CHARACTER" value="true" />
|
||||||
|
<option name="SMART_TABS" value="true" />
|
||||||
|
</indentOptions>
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="LESS">
|
||||||
|
<indentOptions>
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||||
|
<option name="TAB_SIZE" value="2" />
|
||||||
|
<option name="USE_TAB_CHARACTER" value="true" />
|
||||||
|
<option name="SMART_TABS" value="true" />
|
||||||
|
</indentOptions>
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="Markdown">
|
||||||
|
<indentOptions>
|
||||||
|
<option name="INDENT_SIZE" value="2" />
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||||
|
<option name="TAB_SIZE" value="2" />
|
||||||
|
<option name="USE_TAB_CHARACTER" value="true" />
|
||||||
|
<option name="SMART_TABS" value="true" />
|
||||||
|
</indentOptions>
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="SASS">
|
||||||
|
<indentOptions>
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||||
|
<option name="TAB_SIZE" value="2" />
|
||||||
|
<option name="USE_TAB_CHARACTER" value="true" />
|
||||||
|
<option name="SMART_TABS" value="true" />
|
||||||
|
</indentOptions>
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="TypeScript">
|
||||||
|
<indentOptions>
|
||||||
|
<option name="INDENT_SIZE" value="2" />
|
||||||
|
<option name="TAB_SIZE" value="2" />
|
||||||
|
<option name="USE_TAB_CHARACTER" value="true" />
|
||||||
|
<option name="SMART_TABS" value="true" />
|
||||||
|
</indentOptions>
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="VTL">
|
||||||
|
<indentOptions>
|
||||||
|
<option name="INDENT_SIZE" value="2" />
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||||
|
<option name="TAB_SIZE" value="2" />
|
||||||
|
<option name="USE_TAB_CHARACTER" value="true" />
|
||||||
|
<option name="SMART_TABS" value="true" />
|
||||||
|
</indentOptions>
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="XML">
|
||||||
|
<indentOptions>
|
||||||
|
<option name="INDENT_SIZE" value="2" />
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||||
|
<option name="TAB_SIZE" value="2" />
|
||||||
|
<option name="USE_TAB_CHARACTER" value="true" />
|
||||||
|
<option name="SMART_TABS" value="true" />
|
||||||
|
</indentOptions>
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="kotlin">
|
||||||
|
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||||
|
<indentOptions>
|
||||||
|
<option name="INDENT_SIZE" value="2" />
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||||
|
<option name="TAB_SIZE" value="2" />
|
||||||
|
<option name="USE_TAB_CHARACTER" value="true" />
|
||||||
|
<option name="SMART_TABS" value="true" />
|
||||||
|
</indentOptions>
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="protobuf">
|
||||||
|
<indentOptions>
|
||||||
|
<option name="USE_TAB_CHARACTER" value="true" />
|
||||||
|
<option name="SMART_TABS" value="true" />
|
||||||
|
</indentOptions>
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="prototext">
|
||||||
|
<indentOptions>
|
||||||
|
<option name="USE_TAB_CHARACTER" value="true" />
|
||||||
|
<option name="SMART_TABS" value="true" />
|
||||||
|
</indentOptions>
|
||||||
|
</codeStyleSettings>
|
||||||
|
</code_scheme>
|
||||||
|
</component>
|
||||||
12
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
12
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="GrazieInspection" enabled="false" level="TYPO" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="LanguageDetectionInspection" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
|
||||||
|
<option name="processCode" value="true" />
|
||||||
|
<option name="processLiterals" value="true" />
|
||||||
|
<option name="processComments" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
</profile>
|
||||||
|
</component>
|
||||||
9
.idea/markdown.xml
generated
Normal file
9
.idea/markdown.xml
generated
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="MarkdownSettings">
|
||||||
|
<enabledExtensions>
|
||||||
|
<entry key="MermaidLanguageExtension" value="false" />
|
||||||
|
<entry key="PlantUMLLanguageExtension" value="false" />
|
||||||
|
</enabledExtensions>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/treesize.iml" filepath="$PROJECT_DIR$/treesize.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
8
README.md
Normal file
8
README.md
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# treesize
|
||||||
|
|
||||||
|
Rudimentäre Quick-and-dirty-Implementation des tree-Kommandos (Linux), einmal in Java und einmal in Scala
|
||||||
|
|
||||||
|
* 16-Oct-2019 Erstellt und in svn-Repo hochgeladen
|
||||||
|
* 02-Jun-2022 Mit git2svn in lokales git-Repo migriert und in selbstgehosteten Gitea-Server gepusht
|
||||||
|
___
|
||||||
|
RS 02-Jun-2022
|
||||||
87
src/dev/rsems/treesize/j/Test.java
Executable file
87
src/dev/rsems/treesize/j/Test.java
Executable file
@@ -0,0 +1,87 @@
|
|||||||
|
package dev.rsems.treesize.j;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Test {
|
||||||
|
//
|
||||||
|
private static String CORNER = "└── ";
|
||||||
|
private static String BLANK = " ";
|
||||||
|
private static String JUNCTION = "├── ";
|
||||||
|
private static String LINE = "│ ";
|
||||||
|
|
||||||
|
static void recurse(Directory d, int level) {
|
||||||
|
List<Directory> subs = d.children;
|
||||||
|
for (int i = 0; i < subs.size(); i++) {
|
||||||
|
Directory child = subs.get(i);
|
||||||
|
Long ts = child.totalSize;
|
||||||
|
if (true) /* (ts >= 100000000L) */ {
|
||||||
|
StringBuilder sb = new StringBuilder(String.format("D %,16d ", ts));
|
||||||
|
String s = "";
|
||||||
|
Directory temp = child;
|
||||||
|
int loop = 0;
|
||||||
|
while (temp.parent != null) {
|
||||||
|
if (temp.parent.children.indexOf(temp) == temp.parent.children.size() - 1) {
|
||||||
|
if (loop == 0) {
|
||||||
|
s = CORNER + s;
|
||||||
|
} else {
|
||||||
|
s = BLANK + s;
|
||||||
|
}
|
||||||
|
} else if (loop == 0) {
|
||||||
|
s = JUNCTION + s;
|
||||||
|
} else {
|
||||||
|
s = LINE + s;
|
||||||
|
}
|
||||||
|
temp = temp.parent;
|
||||||
|
loop++;
|
||||||
|
}
|
||||||
|
sb.append(s).append(child.fsdir.getName());
|
||||||
|
System.out.println(sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/* if (level <= 4) */
|
||||||
|
|
||||||
|
recurse(child, level + 1);
|
||||||
|
|
||||||
|
int j = 0;
|
||||||
|
for (File f : child.files) {
|
||||||
|
Long fs = f.length();
|
||||||
|
StringBuilder sb = new StringBuilder(String.format(" %,16d ", fs));
|
||||||
|
String s = "";
|
||||||
|
Directory temp = child;
|
||||||
|
int loop = 0;
|
||||||
|
while (temp.parent != null) {
|
||||||
|
if (temp.parent.children.indexOf(temp) == temp.parent.children.size() - 1) {
|
||||||
|
s = BLANK + s;
|
||||||
|
} else if (loop == 0) {
|
||||||
|
s = JUNCTION + s;
|
||||||
|
} else {
|
||||||
|
s = LINE + s;
|
||||||
|
}
|
||||||
|
temp = temp.parent;
|
||||||
|
loop++;
|
||||||
|
}
|
||||||
|
if (j == child.files.length - 1) {
|
||||||
|
s = s + CORNER;
|
||||||
|
} else {
|
||||||
|
s = s + JUNCTION;
|
||||||
|
}
|
||||||
|
sb.append(s).append(f.getName());
|
||||||
|
System.out.println(sb.toString());
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) throws IOException {
|
||||||
|
String parm = args.length > 0 ? args[0] : ".";
|
||||||
|
File dir = new File(parm);
|
||||||
|
// System.out.println(dir.getCanonicalPath() + "\n");
|
||||||
|
Directory d = new Directory(null, dir);
|
||||||
|
String s = String.format("D %,16d", d.totalSize) + " " + d.fsdir.getCanonicalPath();
|
||||||
|
System.out.println(s);
|
||||||
|
recurse(d, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
23
src/dev/rsems/treesize/s/Directory.scala
Executable file
23
src/dev/rsems/treesize/s/Directory.scala
Executable file
@@ -0,0 +1,23 @@
|
|||||||
|
package dev.rsems.treesize.s
|
||||||
|
|
||||||
|
import java.io.File
|
||||||
|
import java.nio.file.Files
|
||||||
|
import scala.collection.mutable.ListBuffer
|
||||||
|
|
||||||
|
class Directory(val fsdir: File, val parent: Directory = null, val sort: Boolean = false) {
|
||||||
|
private var localSize = 0L
|
||||||
|
var children = ListBuffer[Directory]()
|
||||||
|
private val files = fsdir.listFiles
|
||||||
|
if (files != null)
|
||||||
|
localSize = files.filter(f => f.isFile() && !Files.isSymbolicLink(f.toPath)).map(f => f.length).sum
|
||||||
|
var totalSize = localSize
|
||||||
|
private val dirs = fsdir.listFiles
|
||||||
|
if (dirs != null) {
|
||||||
|
totalSize += dirs.filter(f => f.isDirectory() && !Files.isSymbolicLink(f.toPath)).map(dir => {
|
||||||
|
val subdir = new Directory(dir, this, sort)
|
||||||
|
children += subdir
|
||||||
|
subdir.totalSize
|
||||||
|
}).sum
|
||||||
|
if (sort) children = children.sortBy(-_.totalSize)
|
||||||
|
}
|
||||||
|
}
|
||||||
48
src/dev/rsems/treesize/s/Test.scala
Executable file
48
src/dev/rsems/treesize/s/Test.scala
Executable file
@@ -0,0 +1,48 @@
|
|||||||
|
package dev.rsems.treesize.s
|
||||||
|
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
object Test extends App {
|
||||||
|
// ─ │ ┌ ┐ └ ┘ ├ ┤ ┬ ┴ ┼
|
||||||
|
val LineUpAndRight = " \u2514\u2500\u2500 "; // " └── "
|
||||||
|
val LineBlank = " ";
|
||||||
|
val LineVerticalAndRight = " \u251c\u2500\u2500 "; // " ├── "
|
||||||
|
val LineVertical = " \u2502 "; // " │ "
|
||||||
|
|
||||||
|
def recurse(d: Directory, level: Int) {
|
||||||
|
for (child <- d.children) {
|
||||||
|
val ts = child.totalSize
|
||||||
|
val sb = new StringBuilder("%,16d ".format(ts))
|
||||||
|
var s = ""
|
||||||
|
var temp = child
|
||||||
|
var loop = 0
|
||||||
|
while (temp.parent != null) {
|
||||||
|
if (temp.parent.children.indexOf(temp) == temp.parent.children.size - 1) {
|
||||||
|
if (loop == 0) {
|
||||||
|
s = "└─ " + s
|
||||||
|
} else {
|
||||||
|
s = " " + s
|
||||||
|
}
|
||||||
|
} else if (loop == 0) {
|
||||||
|
s = "├─ " + s
|
||||||
|
} else {
|
||||||
|
s = "│ " + s
|
||||||
|
}
|
||||||
|
temp = temp.parent
|
||||||
|
loop += 1
|
||||||
|
}
|
||||||
|
sb.append(s).append(child.fsdir.getName)
|
||||||
|
println(sb.toString)
|
||||||
|
|
||||||
|
// if (level <= 4)
|
||||||
|
|
||||||
|
recurse(child, level + 1)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val dir = new Directory(new File(if (args.length > 0) args(0) else "."))
|
||||||
|
val s = "%,16d".format(dir.totalSize) + " " + dir.fsdir.getCanonicalPath
|
||||||
|
println(s)
|
||||||
|
recurse(dir, 1)
|
||||||
|
}
|
||||||
12
treesize.iml
Normal file
12
treesize.iml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="scala-sdk-2.13.6" level="application" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
Reference in New Issue
Block a user