- Home /
WWW file:// protocol to list a directory
Hi !
Is WWW supporting directory listing with file:// protocol?
I've made a simple function :
public static IEnumerator LoadText(
string uri,
Action<bool, string> onLoad,
Action<float> onFrame = null
)
{
if (OnLoad == null)
throw new NullReferenceException("onLoad");
WWW www = new WWW(uri);
while (!www.isDone)
{
if (onFrame != null)
onFrame(www.progress);
yield return null;
}
if (onFrame != null)
onFrame(www.progress);
if (!string.IsNullOrEmpty(www.error))
{
onLoad(true, www.error);
}
else
{
onLoad(false, www.text);
}
}
I would like to use it to download (text) files and list distant shared directories :
void Awake()
{
// string uri = "file://127.0.0.1/C://path/to/my/file.txt"; // Works
// string uri = "file://127.0.0.1/C://path/to/my/directory"; // Doesn't work
// string uri = "file://127.0.0.1/C://path/to/my/directory/"; // Doesn't work
// string uri = "file:///C://path/to/my/directory/"; // Doesn't work
string uri = "file:///C://path/to/my/directory"; // Doesn't work
StartCoroutine(LoadText(uri, (error, text) =>
{
if (error)
Debug.LogError("Download failed: " + text);
else
Debug.Log("Text: " + text);
}, (progress) =>
{
Debug.Log("Progress: " + (progress * 100).ToString("F2") + "%");
}));
}
Is there someting I'm missing, or directory listing is not supported? I would like to get something like this:
300: file:///C:/
200: filename content-length last-modified file-type
201: .rnd 1024 Tue,%2013%20Aug%202013%2011:46:43%20GMT FILE
201: 5543122f40370829a18c18aeb6b2 0 Tue,%2015%20Apr%202014%2010:29:43%20GMT DIRECTORY
201: Android 0 Wed,%2030%20Apr%202014%2012:48:16%20GMT DIRECTORY
201: IDE 0 Tue,%2012%20Jun%202012%2010:11:49%20GMT DIRECTORY
201: MiKTeX%202.9 4096 Mon,%2015%20Jul%202013%2015:51:26%20GMT DIRECTORY
201: PerfLogs 0 Tue,%2014%20Jul%202009%2003:20:08%20GMT DIRECTORY
201: Program%20Files 12288 Thu,%2017%20Apr%202014%2013:40:00%20GMT DIRECTORY
201: Program%20Files%20%28x86%29 40960 Fri,%2013%20Jun%202014%2008:38:49%20GMT DIRECTORY
201: Projects 8192 Tue,%2017%20Jun%202014%2015:50:59%20GMT DIRECTORY
201: Python33 4096 Thu,%2024%20Oct%202013%2015:24:53%20GMT DIRECTORY
201: SolidWorks%20Data 0 Mon,%2001%20Jul%202013%2015:57:33%20GMT DIRECTORY
201: Sphinx 4096 Thu,%2007%20Nov%202013%2010:36:34%20GMT DIRECTORY
201: Temp 0 Thu,%2017%20Apr%202014%2013:18:55%20GMT DIRECTORY
201: Users 4096 Thu,%2018%20Jul%202013%2010:12:59%20GMT DIRECTORY
201: Windows 24576 Mon,%2016%20Jun%202014%2008:36:38%20GMT DIRECTORY
201: cygwin64 4096 Mon,%2004%20Nov%202013%2017:42:11%20GMT DIRECTORY
201: dev 0 Thu,%2018%20Jul%202013%2014:34:03%20GMT DIRECTORY
201: gitblit 8192 Wed,%2018%20Jun%202014%2007:46:37%20GMT DIRECTORY
201: globdata.ini 1110 Fri,%2011%20Apr%202008%2008:07:18%20GMT FILE
201: julius-4.2.3 0 Fri,%2025%20Oct%202013%2008:47:32%20GMT DIRECTORY
201: msdia80.dll 904704 Fri,%2001%20Dec%202006%2021:37:14%20GMT FILE
201: pagefile.sys 0 Thu,%2001%20Jan%201970%2000:00:00%20GMT FILE
201: scmserver 0 Thu,%2016%20Aug%202012%2008:29:17%20GMT DIRECTORY
201: vcredist.bmp 5686 Fri,%2011%20Apr%202008%2008:07:18%20GMT FILE
201: wamp 4096 Fri,%2022%20Nov%202013%2014:03:07%20GMT DIRECTORY
Comment