file list working

This commit is contained in:
Page Asgardius 2022-12-30 19:51:53 -07:00
parent 99049977c1
commit 4b0651c9c6

View file

@ -155,13 +155,21 @@ public class Uploader extends AppCompatActivity {
fileindex.add(0); fileindex.add(0);
document = filelist[i]; document = filelist[i];
filelist = document.listFiles(); filelist = document.listFiles();
while (treelevel >= 1 && fileindex.get(treelevel) < filelist.length) { while (treelevel >= 1 && fileindex.get(treelevel) < filelist.length+1) {
if(fileindex.get(treelevel) == filelist.length) {
fileindex.remove(treelevel);
document = document.getParentFile();
filelist = document.listFiles();
treelevel--;
filepath.remove(treelevel);
fileindex.set(treelevel, fileindex.get(treelevel)+1);
} else {
filepath.add(filelist[fileindex.get(treelevel)].getName()); filepath.add(filelist[fileindex.get(treelevel)].getName());
if (filelist[fileindex.get(treelevel)].isDirectory()) { if (filelist[fileindex.get(treelevel)].isDirectory()) {
document = filelist[fileindex.get(treelevel)];
filelist = document.listFiles();
treelevel++; treelevel++;
fileindex.add(0); fileindex.add(0);
document = filelist[i];
filelist = document.listFiles();
} else { } else {
System.out.println(String.join("/", filepath)); System.out.println(String.join("/", filepath));
filepath.remove(treelevel); filepath.remove(treelevel);
@ -172,18 +180,11 @@ public class Uploader extends AppCompatActivity {
} }
fileindex.set(treelevel, fileindex.get(treelevel)+1); fileindex.set(treelevel, fileindex.get(treelevel)+1);
} }
if(fileindex.get(treelevel) == filelist.length) {
fileindex.remove(treelevel);
document = document.getParentFile();
filelist = document.listFiles();
treelevel--;
filepath.remove(treelevel);
fileindex.set(treelevel, fileindex.get(treelevel)+1);
} }
} }
document = document.getParentFile(); //document = document.getParentFile();
filelist = document.listFiles(); //filelist = document.listFiles();
treelevel--; //treelevel--;
} else { } else {
System.out.println(String.join("/", filepath)); System.out.println(String.join("/", filepath));
if(filelist[i].length()%MAX_SINGLE_PART_UPLOAD_BYTES == 0) { if(filelist[i].length()%MAX_SINGLE_PART_UPLOAD_BYTES == 0) {