Exemple #1
0
 public static function getPresentations()
 {
     $presentations = array();
     $list = \OC\Files\Filesystem::searchByMime('text/impress');
     foreach ($list as $l) {
         $info = pathinfo($l);
         $size = \OC\Files\Filesystem::filesize($l);
         $mtime = \OC\Files\Filesystem::filemtime($l);
         $entry = array('url' => $l, 'name' => $info['filename'], 'size' => $size, 'mtime' => $mtime);
         $presentations[] = $entry;
     }
     return $presentations;
 }
 public function testOwnerWritesToSingleFileShare()
 {
     $this->loginAsUser(self::TEST_FILES_SHARING_API_USER1);
     Filesystem::file_put_contents('/foo.txt', 'longer_bar');
     $t = (int) Filesystem::filemtime('/foo.txt') - 1;
     Filesystem::touch('/foo.txt', $t);
     $this->assertEtagsNotChanged([self::TEST_FILES_SHARING_API_USER4, self::TEST_FILES_SHARING_API_USER3]);
     $this->assertEtagsChanged([self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2]);
     $this->assertAllUnchanged();
 }
        \OC\Files\Filesystem::mkdir($dir);
        if (!\OC\Files\Filesystem::touch($dir . '/' . $file)) {
            OCP\JSON::error(array("data" => array("message" => "Error when creating new file!")));
            OCP\Util::writeLog('files_svgedit', "Failed to create file: " . $path, OC_Log::ERROR);
            exit;
        }
    }
    // file should be existing now
    $writable = \OC\Files\Filesystem::isUpdatable($path);
    if ($writable) {
        if ($b64encoded) {
            $b64prefix = 'data:' . $b64type . ';base64,';
            if (strpos($filecontents, $b64prefix) === 0) {
                $filecontents = base64_decode(substr($filecontents, strlen($b64prefix)));
            }
        }
        \OC\Files\Filesystem::file_put_contents($path, $filecontents);
        // Clear statcache
        clearstatcache();
        // Get new mtime
        $newmtime = \OC\Files\Filesystem::filemtime($path);
        OCP\JSON::success(array('data' => array('mtime' => $newmtime)));
    } else {
        // Not writable!
        OCP\JSON::error(array('data' => array('message' => 'Insufficient permissions')));
        OCP\Util::writeLog('files_svgedit', "User does not have permission to write to file: " . $path, OC_Log::ERROR);
    }
} else {
    OCP\JSON::error(array('data' => array('message' => 'File path or mtime not supplied')));
    OCP\Util::writeLog('files_svgedit', "Invalid path supplied:" . $path, OC_Log::ERROR);
}
 /**
  * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  */
 public static function filemtime($path)
 {
     return \OC\Files\Filesystem::filemtime($path);
 }
Exemple #5
0
            }
            break;
        case 'play':
            $ftype = \OC\Files\Filesystem::getMimeType($arguments['path']);
            if (substr($ftype, 0, 5) != 'audio' and $ftype != 'application/ogg') {
                echo 'Not an audio file';
                exit;
            }
            $songId = $collection->getSongByPath($arguments['path']);
            $collection->registerPlay($songId);
            header('Content-Type:' . $ftype);
            \OCP\Response::enableCaching(3600 * 24);
            // 24 hour
            header('Accept-Ranges: bytes');
            header('Content-Length: ' . \OC\Files\Filesystem::filesize($arguments['path']));
            $mtime = \OC\Files\Filesystem::filemtime($arguments['path']);
            \OCP\Response::setLastModifiedHeader($mtime);
            \OC\Files\Filesystem::readfile($arguments['path']);
            exit;
        case 'find_music':
            $scanner = new Scanner($collection);
            $music = $scanner->getMusic();
            \OCP\JSON::encodedPrint($music);
            exit;
    }
}
class ScanWatcher
{
    /**
     * @var \OC_EventSource $eventSource;
     */