+ return $lockpath;
+ } else {
+ // We can't create a subdirectory, strange.
+ // But the directory seems to work, so we use it but don't store it.
+ return $temppath;
+ }
+ }
+
+ // Reaching this point means that the operating system is configured badly.
+ return "";
+}
+
+/**
+ * @brief Returns the path where spool files are stored
+ *
+ * @return string Spool path
+ */
+function get_spoolpath() {
+ $spoolpath = get_config('system','spoolpath');
+ if (($spoolpath != "") AND App::directory_usable($spoolpath)) {
+ // We have a spool path and it is usable
+ return $spoolpath;
+ }
+
+ // We don't have a working preconfigured spool path, so we take the temp path.
+ $temppath = get_temppath();
+
+ if ($temppath != "") {
+ // To avoid any interferences with other systems we create our own directory
+ $spoolpath = $temppath."/spool";
+ if (!is_dir($spoolpath)) {
+ mkdir($spoolpath);
+ }
+
+ if (App::directory_usable($spoolpath)) {
+ // The new path is usable, we are happy
+ set_config("system", "spoolpath", $spoolpath);
+ return $spoolpath;
+ } else {
+ // We can't create a subdirectory, strange.
+ // But the directory seems to work, so we use it but don't store it.
+ return $temppath;