当前位置: 首页>>代码示例>>PHP>>正文


PHP OC_Filesystem::file_put_contents方法代码示例

本文整理汇总了PHP中OC_Filesystem::file_put_contents方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Filesystem::file_put_contents方法的具体用法?PHP OC_Filesystem::file_put_contents怎么用?PHP OC_Filesystem::file_put_contents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OC_Filesystem的用法示例。


在下文中一共展示了OC_Filesystem::file_put_contents方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create_execution_env

/**
 * 
 * @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;
}
开发者ID:v-iacovella,项目名称:NeuroBox,代码行数:35,代码来源:execute.php

示例2: testSimple

 public function testSimple()
 {
     $file = OC::$SERVERROOT . '/3rdparty/MDB2.php';
     $original = file_get_contents($file);
     OC_Filesystem::file_put_contents('/file', $original);
     OC_FileProxy::$enabled = false;
     $stored = OC_Filesystem::file_get_contents('/file');
     OC_FileProxy::$enabled = true;
     $fromFile = OC_Filesystem::file_get_contents('/file');
     $this->assertNotEqual($original, $stored);
     $this->assertEqual($original, $fromFile);
 }
开发者ID:jaeindia,项目名称:ownCloud-Enhancements,代码行数:12,代码来源:proxy.php

示例3: createFile

 /**
  * Creates a new file in the directory
  *
  * Data will either be supplied as a stream resource, or in certain cases
  * as a string. Keep in mind that you may have to support either.
  *
  * After succesful creation of the file, you may choose to return the ETag
  * of the new file here.
  *
  * The returned ETag must be surrounded by double-quotes (The quotes should
  * be part of the actual string).
  *
  * If you cannot accurately determine the ETag, you should not return it.
  * If you don't store the file exactly as-is (you're transforming it
  * somehow) you should also not return an ETag.
  *
  * This means that if a subsequent GET to this new file does not exactly
  * return the same contents of what was submitted here, you are strongly
  * recommended to omit the ETag.
  *
  * @param string $name Name of the file
  * @param resource|string $data Initial payload
  * @return null|string
  */
 public function createFile($name, $data = null)
 {
     if (isset($_SERVER['HTTP_OC_CHUNKED'])) {
         $info = OC_FileChunking::decodeName($name);
         if (empty($info)) {
             throw new Sabre_DAV_Exception_NotImplemented();
         }
         $chunk_handler = new OC_FileChunking($info);
         $chunk_handler->store($info['index'], $data);
         if ($chunk_handler->isComplete()) {
             $newPath = $this->path . '/' . $info['name'];
             $chunk_handler->file_assemble($newPath);
             return OC_Connector_Sabre_Node::getETagPropertyForPath($newPath);
         }
     } else {
         $newPath = $this->path . '/' . $name;
         OC_Filesystem::file_put_contents($newPath, $data);
         return OC_Connector_Sabre_Node::getETagPropertyForPath($newPath);
     }
     return null;
 }
开发者ID:ryanshoover,项目名称:core,代码行数:45,代码来源:directory.php

示例4: testBinary

 public function testBinary()
 {
     $file = __DIR__ . '/binary';
     $original = file_get_contents($file);
     OC_Filesystem::file_put_contents('/file', $original);
     OC_FileProxy::$enabled = false;
     $stored = OC_Filesystem::file_get_contents('/file');
     OC_FileProxy::$enabled = true;
     $fromFile = OC_Filesystem::file_get_contents('/file');
     $this->assertNotEqual($original, $stored);
     $this->assertEqual(strlen($original), strlen($fromFile));
     $this->assertEqual($original, $fromFile);
     $file = __DIR__ . '/zeros';
     $original = file_get_contents($file);
     OC_Filesystem::file_put_contents('/file', $original);
     OC_FileProxy::$enabled = false;
     $stored = OC_Filesystem::file_get_contents('/file');
     OC_FileProxy::$enabled = true;
     $fromFile = OC_Filesystem::file_get_contents('/file');
     $this->assertNotEqual($original, $stored);
     $this->assertEqual(strlen($original), strlen($fromFile));
 }
开发者ID:ryanshoover,项目名称:core,代码行数:22,代码来源:proxy.php

示例5: put

 /**
  * Updates the data
  *
  * @param resource $data
  * @return void
  */
 public function put($data)
 {
     OC_Filesystem::file_put_contents($this->path, $data);
 }
开发者ID:noci2012,项目名称:owncloud,代码行数:10,代码来源:file.php

示例6: isset

// Get paramteres
$filecontents = isset($_POST['filecontents']) ? $_POST['filecontents'] : false;
$path = isset($_POST['path']) ? $_POST['path'] : '';
$mtime = isset($_POST['mtime']) ? $_POST['mtime'] : '';
if ($path != '' && $mtime != '' && $filecontents) {
    // Get file mtime
    $filemtime = OC_Filesystem::filemtime($path);
    if ($mtime != $filemtime) {
        // Then the file has changed since opening
        OCP\JSON::error();
        OCP\Util::writeLog('files_texteditor', "File: " . $path . " modified since opening.", OCP\Util::ERROR);
    } else {
        // File same as when opened
        // Save file
        if (OC_Filesystem::is_writable($path)) {
            OC_Filesystem::file_put_contents($path, $filecontents);
            // Clear statcache
            clearstatcache();
            // Get new mtime
            $newmtime = OC_Filesystem::filemtime($path);
            OCP\JSON::success(array('data' => array('mtime' => $newmtime)));
        } else {
            // Not writeable!
            OCP\JSON::error(array('data' => array('message' => 'Insufficient permissions')));
            OCP\Util::writeLog('files_texteditor', "User does not have permission to write to file: " . $path, OCP\Util::ERROR);
        }
    }
} else {
    if ($path == '') {
        OCP\JSON::error(array('data' => array('message' => 'File path not supplied')));
        OCP\Util::writeLog('files_texteditor', 'No file path supplied', OCP\Util::ERROR);
开发者ID:noci2012,项目名称:owncloud,代码行数:31,代码来源:savefile.php

示例7: put

 /**
  * Updates the data
  *
  * The data argument is a readable stream resource.
  *
  * After a succesful put operation, you may choose to return an ETag. The
  * etag must always be surrounded by double-quotes. These quotes must
  * appear in the actual string you're returning.
  *
  * Clients may use the ETag from a PUT request to later on make sure that
  * when they update the file, the contents haven't changed in the mean
  * time.
  *
  * If you don't plan to store the file byte-by-byte, and you return a
  * different object on a subsequent GET you are strongly recommended to not
  * return an ETag, and just return null.
  *
  * @param resource $data
  * @return string|null
  */
 public function put($data)
 {
     OC_Filesystem::file_put_contents($this->path, $data);
     return OC_Connector_Sabre_Node::getETagPropertyForPath($this->path);
 }
开发者ID:noci2012,项目名称:owncloud,代码行数:25,代码来源:file.php

示例8: array

    OCP\JSON::error(array("data" => array("message" => "Invalid Filename")));
    exit;
}
if ($source) {
    if (substr($source, 0, 8) != 'https://' and substr($source, 0, 7) != 'http://') {
        OCP\JSON::error(array("data" => array("message" => "Not a valid source")));
        exit;
    }
    $sourceStream = fopen($source, 'rb');
    $target = $dir . '/' . $filename;
    $result = OC_Filesystem::file_put_contents($target, $sourceStream);
    if ($result) {
        $mime = OC_Filesystem::getMimetype($target);
        OCP\JSON::success(array("data" => array('mime' => $mime)));
        exit;
    } else {
        OCP\JSON::error(array("data" => array("message" => "Error while downloading " . $source . ' to ' . $target)));
        exit;
    }
} else {
    if ($content) {
        if (OC_Filesystem::file_put_contents($dir . '/' . $filename, $content)) {
            OCP\JSON::success(array("data" => array('content' => $content)));
            exit;
        }
    } elseif (OC_Files::newFile($dir, $filename, 'file')) {
        OCP\JSON::success(array("data" => array('content' => $content)));
        exit;
    }
}
OCP\JSON::error(array("data" => array("message" => "Error when creating the file")));
开发者ID:jaeindia,项目名称:ownCloud-Enhancements,代码行数:31,代码来源:newfile.php

示例9: postFopen

 public function postFopen($path, &$result)
 {
     if (!$result) {
         return $result;
     }
     $meta = stream_get_meta_data($result);
     if (self::isEncrypted($path)) {
         fclose($result);
         $result = fopen('crypt://' . $path, $meta['mode']);
     } elseif (self::shouldEncrypt($path) and $meta['mode'] != 'r' and $meta['mode'] != 'rb') {
         if (OC_Filesystem::file_exists($path) and OC_Filesystem::filesize($path) > 0) {
             //first encrypt the target file so we don't end up with a half encrypted file
             OCP\Util::writeLog('files_encryption', 'Decrypting ' . $path . ' before writing', OCP\Util::DEBUG);
             $tmp = fopen('php://temp');
             OCP\Files::streamCopy($result, $tmp);
             fclose($result);
             OC_Filesystem::file_put_contents($path, $tmp);
             fclose($tmp);
         }
         $result = fopen('crypt://' . $path, $meta['mode']);
     }
     return $result;
 }
开发者ID:noci2012,项目名称:owncloud,代码行数:23,代码来源:proxy.php

示例10: testHooks

 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);
 }
开发者ID:ryanshoover,项目名称:core,代码行数:22,代码来源:filesystem.php

示例11: createFile

 /**
  * Creates a new file in the directory
  *
  * data is a readable stream resource
  *
  * @param string $name Name of the file
  * @param resource $data Initial payload
  * @return void
  */
 public function createFile($name, $data = null)
 {
     $newPath = $this->path . '/' . $name;
     OC_Filesystem::file_put_contents($newPath, $data);
 }
开发者ID:jaeindia,项目名称:ownCloud-Enhancements,代码行数:14,代码来源:directory.php

示例12: save_job_info

function save_job_info($study, $jobid, $jobinfo)
{
    $path = get_job_info_file($study, $jobid);
    if (is_array($jobinfo)) {
        $json = json_encode($jobinfo);
        OC_Filesystem::file_put_contents($path, $json);
    }
}
开发者ID:v-iacovella,项目名称:NeuroBox,代码行数:8,代码来源:common.php


注:本文中的OC_Filesystem::file_put_contents方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。