/** * * @param type $study_name the name of the study directory * @return the job id */ function create_execution_env($study_name, $script_name) { include 'config.inc.php'; $jobid = create_job_id($study_name, $script_name); $job_dir = get_job_exec_dir($jobid); while (is_dir($job_dir)) { // the sandbox directory is already existing, sleep 1 second and generate another ID sleep(1); $jobid = create_job_id($study_name, $script_name); $job_dir = get_job_exec_dir($jobid); } mkdir($job_dir, 0777, true); // [job_root_dir]/[job_id]/data --> ../../data/[fs_root]/[study_name]/data $datadir = $NC_CONFIG["symlink_prefix"] . "/" . $study_name . "/data"; $pipelinedir = get_absolute_path($study_name . "/pipeline"); $resultsdir = $NC_CONFIG["symlink_prefix"] . "/" . $study_name . "/results/" . $jobid; OC_Filesystem::mkdir("{$study_name}/results/{$jobid}"); # le dir /data e /results sono link simbolici alle vere directory del caso di studio mkdir($job_dir . "/pipeline"); symlink($datadir, $job_dir . "/data"); symlink($resultsdir, $job_dir . "/results"); # creo il file in cui verrà rediretto lo standard output $date = date("Y-m-d H:i:s"); OC_Filesystem::file_put_contents(get_job_output_file($study_name, $jobid), "Standard output for job {$jobid}, run at {$date}\n"); $jobinfo = array("jobid" => $jobid, "study" => $study_name); save_job_info($study_name, $jobid, $jobinfo); # copia gli script del caso di studio nella pipeline copy_dir($pipelinedir, $job_dir . "/pipeline"); return $jobid; }
public function __construct($arguments) { $this->datadir = $arguments['datadir']; if (OC_Share::getItemsInFolder($this->datadir)) { if (!OC_Filesystem::is_dir($this->datadir)) { OC_Filesystem::mkdir($this->datadir); } } else { if (OC_Filesystem::is_dir($this->datadir)) { OC_Filesystem::rmdir($this->datadir); } } $this->datadir .= "/"; }
public static function createDataScope($appUrl, $userAddress, $dataScope) { $token = uniqid(); self::addToken($token, $appUrl, $userAddress, $dataScope); //TODO: input checking on $userAddress and $dataScope list($userName, $userHost) = explode('@', $userAddress); OC_Util::setupFS(OC_User::getUser()); $scopePathParts = array('remoteStorage', 'webdav', $userHost, $userName, $dataScope); for ($i = 0; $i <= count($scopePathParts); $i++) { $thisPath = '/' . implode('/', array_slice($scopePathParts, 0, $i)); if (!OC_Filesystem::file_exists($thisPath)) { OC_Filesystem::mkdir($thisPath); } } return $token; }
public static function createCategories($appUrl, $categories) { $token = uniqid(); OC_Util::setupFS(OC_User::getUser()); self::addToken($token, $appUrl, $categories); foreach (explode(',', $categories) as $category) { //TODO: input checking on $category $scopePathParts = array('remoteStorage', $category); for ($i = 0; $i <= count($scopePathParts); $i++) { $thisPath = '/' . implode('/', array_slice($scopePathParts, 0, $i)); if (!OC_Filesystem::file_exists($thisPath)) { OC_Filesystem::mkdir($thisPath); } } } return base64_encode('remoteStorage:' . $token); }
/** * create a new file or folder * * @param dir $dir * @param file $name * @param type $type */ public static function newFile($dir, $name, $type) { if (OC_User::isLoggedIn()) { $file = $dir . '/' . $name; if ($type == 'dir') { return OC_Filesystem::mkdir($file); } elseif ($type == 'file') { $fileHandle = OC_Filesystem::fopen($file, 'w'); if ($fileHandle) { fclose($fileHandle); return true; } else { return false; } } } }
/** * Creates a new subdirectory * * @param string $name * @return void */ public function createDirectory($name) { $newPath = $this->path . '/' . $name; OC_Filesystem::mkdir($newPath); }
public function testHooks() { if (OC_Filesystem::getView()) { $user = OC_User::getUser(); } else { $user = uniqid(); OC_Filesystem::init('/' . $user . '/files'); } OC_Hook::clear('OC_Filesystem'); OC_Hook::connect('OC_Filesystem', 'post_write', $this, 'dummyHook'); OC_Filesystem::mount('OC_Filestorage_Temporary', array(), '/'); $rootView = new OC_FilesystemView(''); $rootView->mkdir('/' . $user); $rootView->mkdir('/' . $user . '/files'); OC_Filesystem::file_put_contents('/foo', 'foo'); OC_Filesystem::mkdir('/bar'); OC_Filesystem::file_put_contents('/bar//foo', 'foo'); $tmpFile = OC_Helper::tmpFile(); file_put_contents($tmpFile, 'foo'); $fh = fopen($tmpFile, 'r'); OC_Filesystem::file_put_contents('/bar//foo', $fh); }
* version 3 of the License, or any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU AFFERO GENERAL PUBLIC LICENSE for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see <http://www.gnu.org/licenses/>. * */ require_once '../../../../lib/base.php'; OC_JSON::checkAppEnabled('ocdownloader'); OC_JSON::checkLoggedIn(); if (!OC_Filesystem::is_dir('/Downloads')) { OC_Filesystem::mkdir('/Downloads'); } $pr = $_POST['pr']; switch ($pr) { case 'web': $k = OC_ocDownloaderFile::getHttpFile($_POST['url']); break; default: if (preg_match('/^pr_([0-9]{1,4})$/', $pr, $m)) { $pr_name = OC_ocDownloader::getProvider($m[1]); $user_info = OC_ocDownloader::getUserProviderInfo($m[1]); $pr_name = strtolower($pr_name['pr_name']); if (file_exists(OC::$SERVERROOT . '/apps/ocdownloader/providers/' . $pr_name . '.php')) { require_once OC::$SERVERROOT . '/apps/ocdownloader/providers/' . $pr_name . '.php'; } }