+
+ //HACKETY HACK HACK (should really be a seperate function)
+ if (strcmp(action, "list") == 0)
+ {
+ DIR * dir = opendir(context->user_name);
+ if (dir == NULL)
+ {
+ FCGI_RejectJSON(context, "Failed to open user directory");
+ return;
+ }
+ struct dirent * ent;
+ FCGI_BeginJSON(context, STATUS_OK);
+ FCGI_JSONKey("experiments");
+ FCGI_PrintRaw("[");
+
+ bool first = true;
+ while ((ent = readdir(dir)) != NULL)
+ {
+ char * c;
+ for (c = ent->d_name; *c != '\0' && *c != '.'; ++c);
+
+ if (*c != '\0' && strcmp(c, ".exp") == 0)
+ {
+ if (!first)
+ FCGI_PrintRaw(",");
+ *c = '\0'; // Ummm... probably not a great idea
+ FCGI_PrintRaw(ent->d_name);
+ first = false;
+ }
+ }
+ FCGI_PrintRaw("]");
+ FCGI_EndJSON();
+
+ return; // Dear god this is terrible
+ }
+ //TODO: Need a "load" action to set data files (but not run) from a past experiment
+
+ //TODO: Need a "delete" action so that people can overwrite experiments (without all this "force" shenanigans)