if(pathChanged)
{
pathChanged = false;
//TODO .debug("before DirLister");
DirLister dir = new DirLister(con, sortMode);
while(!dir.finished)
{
LocalIO.pause(10);
}
if(dir.isOk())
{
//TODO .debug("dir is ok");
length = dir.getLength();
dirEntry = new DirEntry[length];
files = dir.list();
String[] fSize = dir.sList();
int[] perms = dir.getPermissions();
// --------- sorting aphabetically ------------
// is now in DirLister
/*
if(Settings.sortDir)
{
String[] tmpx = new String[length];
//if(fSize != null) System.out.println(":"+length+":"+fSize.length+":"+files.length);
int pLength = length;
if(perms != null)
{
pLength = perms.length;
}
//System.out.println(files.length + ":" + fSize.length+":"+ pLength + ":"+ length);
if((fSize.length != files.length) ||
(pLength != files.length) ||
(length != files.length))
{
System.out.println("Sort mismatch - hopefully ignoring it...");
}
for(int x = 0; x < length; x++)
{
if(perms != null)
{
tmpx[x] = files[x] + "@@@" + fSize[x] + "@@@" +
perms[x];
}
else
{
Log.out("permissions are skipped");
tmpx[x] = files[x] + "@@@" + fSize[x];
}
}
LocalIO.sortStrings(tmpx);
for(int y = 0; y < length; y++)
{
files[y] = tmpx[y].substring(0,
tmpx[y].indexOf("@@@"));
String tmp = tmpx[y].substring(tmpx[y].indexOf("@@@") +
3);
if(tmp.indexOf("@@@") > 0)
{
fSize[y] = tmp.substring(0,
tmp.lastIndexOf("@@@"));
}
else
{
fSize[y] = tmp;
}
if(perms != null)
{
perms[y] = Integer.parseInt(tmpx[y].substring(tmpx[y].lastIndexOf("@@@") +
3));
}
}
}
*/
// ----------- end sorting --------------------
for(int i = 0; i < length; i++)
{
//System.out.println(files[i]);
if((files == null) || (files[i] == null))
{
//System.out.println("Critical error, files or files[i] is null!\nPlease report when and how this happened...");
System.out.println("skipping setDirList, files or files[i] is null!");
return;
//System.exit(0);
}
//Log.debug("adding: " + files[i]);
dirEntry[i] = new DirEntry(files[i], this);
if(dirEntry[i] == null)
{
System.out.println("\nskipping setDirList, dirEntry[i] is null!");
return;
}
if(dirEntry[i].file == null)
{
System.out.println("\nskipping setDirList, dirEntry[i].file is null!");
return;
}
if(perms != null)
{
dirEntry[i].setPermission(perms[i]);
}
if(fSize[i].startsWith("@"))
{
fSize[i] = fSize[i].substring(1);
}
dirEntry[i].setFileSize(Long.parseLong(fSize[i]));
if(dirEntry[i].file.endsWith("/"))
{
dirEntry[i].setDirectory();
}
else
{
dirEntry[i].setFile();
}
if(dirEntry[i].file.endsWith("###"))
{
dirEntry[i].setLink();
}
//------ date parser -------
Object[] d = dir.getDates();
if(d != null)
{
dirEntry[i].setDate((Date) d[i]);
}