|
@@ -15,44 +15,44 @@ namespace BuildOurOwnBabylonJSServer.Controllers
|
|
|
[ActionName(BuildOurOwnBabylonJSController.GetFileContentActionName)]
|
|
|
public ActionResult GetFileContent(string rootPath, string relPath)
|
|
|
{
|
|
|
- var babylonJSPath = Path.Combine(Server.MapPath("~"), rootPath);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var babylonJSPath = Path.Combine(Server.MapPath("~"), rootPath);
|
|
|
|
|
|
- var absPath = Path.Combine(babylonJSPath, relPath);
|
|
|
+ var absPath = Path.Combine(babylonJSPath, relPath);
|
|
|
|
|
|
- var type = "";
|
|
|
- var extension = "";
|
|
|
+ var type = "";
|
|
|
+ var extension = "";
|
|
|
|
|
|
- if (!String.IsNullOrEmpty(relPath))
|
|
|
- extension = Path.GetExtension(relPath).ToLower();
|
|
|
+ if (!String.IsNullOrEmpty(relPath))
|
|
|
+ extension = Path.GetExtension(relPath).ToLower();
|
|
|
|
|
|
- switch (extension)
|
|
|
- {
|
|
|
- case ".js":
|
|
|
- case ".babylon":
|
|
|
- case ".manifest":
|
|
|
- type = "text/javascript";
|
|
|
- break;
|
|
|
+ switch (extension)
|
|
|
+ {
|
|
|
+ case ".js":
|
|
|
+ case ".babylon":
|
|
|
+ case ".manifest":
|
|
|
+ type = "text/javascript";
|
|
|
+ break;
|
|
|
|
|
|
- case ".png":
|
|
|
- type = "image/png";
|
|
|
- break;
|
|
|
+ case ".png":
|
|
|
+ type = "image/png";
|
|
|
+ break;
|
|
|
|
|
|
- case ".jpeg":
|
|
|
- case ".jpg":
|
|
|
- type = "image/jpeg";
|
|
|
- break;
|
|
|
+ case ".jpeg":
|
|
|
+ case ".jpg":
|
|
|
+ type = "image/jpeg";
|
|
|
+ break;
|
|
|
|
|
|
- case ".bmp":
|
|
|
- type = "image/bmp";
|
|
|
- break;
|
|
|
-
|
|
|
- default:
|
|
|
- type = "text/plain";
|
|
|
- break;
|
|
|
- }
|
|
|
+ case ".bmp":
|
|
|
+ type = "image/bmp";
|
|
|
+ break;
|
|
|
|
|
|
- try
|
|
|
- {
|
|
|
+ default:
|
|
|
+ type = "text/plain";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
return File(new FileStream(absPath, FileMode.Open), type);
|
|
|
}
|
|
|
catch
|
|
@@ -64,27 +64,37 @@ namespace BuildOurOwnBabylonJSServer.Controllers
|
|
|
[ActionName(BuildOurOwnBabylonJSController.GetBabylonScenesActionName)]
|
|
|
public string GetBabylonScenes(string rootPath)
|
|
|
{
|
|
|
- var dir = new DirectoryInfo(rootPath);
|
|
|
- var subDirs = dir.GetDirectories();
|
|
|
- var files = new List<JObject>();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var dir = new DirectoryInfo(rootPath);
|
|
|
+ var subDirs = dir.GetDirectories();
|
|
|
+ var files = new List<JObject>();
|
|
|
|
|
|
- foreach (var directory in subDirs) {
|
|
|
- var babylonFiles = directory.GetFiles("*.babylon");
|
|
|
- if (babylonFiles.Length == 0) {
|
|
|
- continue;
|
|
|
- }
|
|
|
+ foreach (var directory in subDirs)
|
|
|
+ {
|
|
|
+ var babylonFiles = directory.GetFiles("*.babylon");
|
|
|
|
|
|
- foreach (var file in babylonFiles) {
|
|
|
- var linkName = directory.Name + (file.Name.Contains(".incremental.babylon") ? " - Incremental" : "");
|
|
|
- files.Add(new JObject(
|
|
|
- new JProperty("url", Url.Action("Index", "BabylonJSDemo", new { demoFolderName = directory.Name, demoFile = file.Name })),
|
|
|
- new JProperty("linkName", linkName)
|
|
|
- ));
|
|
|
+ if (babylonFiles.Length == 0)
|
|
|
+ continue;
|
|
|
+
|
|
|
+ foreach (var file in babylonFiles)
|
|
|
+ {
|
|
|
+ var linkName = directory.Name + (file.Name.Contains(".incremental.babylon") ? " - Incremental" : "");
|
|
|
+ files.Add(new JObject(
|
|
|
+ new JProperty("url", Url.Action("Index", "BabylonJSDemo", new { demoFolderName = directory.Name, demoFile = file.Name })),
|
|
|
+ new JProperty("linkName", linkName)
|
|
|
+ ));
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- var json = new JObject(new JProperty("files", files));
|
|
|
- return json.ToString(Newtonsoft.Json.Formatting.None);
|
|
|
+ var json = new JObject(new JProperty("files", files));
|
|
|
+ return json.ToString(Newtonsoft.Json.Formatting.None);
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+ var json = new JObject(new JProperty("files", ""));
|
|
|
+ return json.ToString(Newtonsoft.Json.Formatting.None);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|