<commit_before><?php
/**
 * Copyright (c) 2012 <NAME> <<EMAIL>>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */

namespace OC\Files\Storage;

/**
 * Storage backend class for providing common filesystem operation methods
 * which are not storage-backend specific.
 *
 * \OC\Files\Storage\Common is never used directly; it is extended by all other
 * storage backends, where its methods may be overridden, and additional
 * (backend-specific) methods are defined.
 *
 * Some \OC\Files\Storage\Common methods call functions which are first defined
 * in classes which extend it, e.g. $this->stat() .
 */

abstract class Common extends \OC\Files\Storage\Storage {

	public function __construct($parameters) {}
// 	abstract public function getId();
// 	abstract public function mkdir($path);
// 	abstract public function rmdir($path);
// 	abstract public function opendir($path);
	public function is_dir($path) {
		return $this->filetype($path)=='dir';
	}
	public function is_file($path) {
		return $this->filetype($path)=='file';
	}
// 	abstract public function stat($path);
// 	abstract public function filetype($path);
	public function filesize($path) {
		if($this->is_dir($path)) {
			return 0;//by definition
		}else{
			$stat = $this->stat($path);
			return $stat['size'];
		}
	}
	public function isCreatable($path) {
		return $this->isUpdatable($path);
	}
// 	abstract public function isReadable($path);
// 	abstract public function isUpdatable($path);
	public function isDeletable($path) {
		return $this->isUpdatable($path);
	}
	public function isSharable($path) {
		return $this->isReadable($path);
	}
	public function getPermissions($path){
		$permissions = 0;
		if($this->isCreatable($path)){
			$permissions |= OCP\Share::PERMISSION_CREATE;
		}
		if($this->isReadable($path)){
			$permissions |= OCP\Share::PERMISSION_READ;
		}
		if($this->isUpdatable($path)){
			$permissions |= OCP\Share::PERMISSION_UPDATE;
		}
		if($this->isDeletable($path)){
			$permissions |= OCP\Share::PERMISSION_DELETE;
		}
		if($this->isSharable($path)){
			$permissions |= OCP\Share::PERMISSION_SHARE;
		}
		return $permissions;
	}
// 	abstract public function file_exists($path);
	public function filectime($path) {
		$stat = $this->stat($path);
		return $stat['ctime'];
	}
	public function filemtime($path) {
		$stat = $this->stat($path);
		return $stat['mtime'];
	}
	public function fileatime($path) {
		$stat = $this->stat($path);
		return $stat['atime'];
	}
	public function file_get_contents($path) {
		$handle = $this->fopen($path, "r");
		if(!$handle) {
			return false;
		}
		$size=$this->filesize($path);<commit_msg>correct namespace usage in common filestorage backend<commit_after><?php
/**
 * Copyright (c) 2012 <NAME> <<EMAIL>>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */

namespace OC\Files\Storage;

/**
 * Storage backend class for providing common filesystem operation methods
 * which are not storage-backend specific.
 *
 * \OC\Files\Storage\Common is never used directly; it is extended by all other
 * storage backends, where its methods may be overridden, and additional
 * (backend-specific) methods are defined.
 *
 * Some \OC\Files\Storage\Common methods call functions which are first defined
 * in classes which extend it, e.g. $this->stat() .
 */

abstract class Common extends \OC\Files\Storage\Storage {

	public function __construct($parameters) {}
// 	abstract public function getId();
// 	abstract public function mkdir($path);
// 	abstract public function rmdir($path);
// 	abstract public function opendir($path);
	public function is_dir($path) {
		return $this->filetype($path)=='dir';
	}
	public function is_file($path) {
		return $this->filetype($path)=='file';
	}
// 	abstract public function stat($path);
// 	abstract public function filetype($path);
	public function filesize($path) {
		if($this->is_dir($path)) {
			return 0;//by definition
		}else{
			$stat = $this->stat($path);
			return $stat['size'];
		}
	}
	public function isCreatable($path) {
		return $this->isUpdatable($path);
	}
// 	abstract public function isReadable($path);
// 	abstract public function isUpdatable($path);
	public function isDeletable($path) {
		return $this->isUpdatable($path);
	}
	public function isSharable($path) {
		return $this->isReadable($path);
	}
	public function getPermissions($path){
		$permissions = 0;
		if($this->isCreatable($path)){
			$permissions |= \OCP\Share::PERMISSION_CREATE;
		}
		if($this->isReadable($path)){
			$permissions |= \OCP\Share::PERMISSION_READ;
		}
		if($this->isUpdatable($path)){
			$permissions |= \OCP\Share::PERMISSION_UPDATE;
		}
		if($this->isDeletable($path)){
			$permissions |= \OCP\Share::PERMISSION_DELETE;
		}
		if($this->isSharable($path)){
			$permissions |= \OCP\Share::PERMISSION_SHARE;
		}
		return $permissions;
	}
// 	abstract public function file_exists($path);
	public function filectime($path) {
		$stat = $this->stat($path);
		return $stat['ctime'];
	}
	public function filemtime($path) {
		$stat = $this->stat($path);
		return $stat['mtime'];
	}
	public function fileatime($path) {
		$stat = $this->stat($path);
		return $stat['atime'];
	}
	public function file_get_contents($path) {
		$handle = $this->fopen($path, "r");
		if(!$handle) {
			return false;
		}
		$size=$this->filesize($path);
{'fraction_non_alphanumeric': 0.15618661257606492, 'fraction_numerical': 0.0025815969020837174, 'mean_word_length': 4.456740442655936, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '788671', 'n_tokens_mistral': 1876, 'n_tokens_neox': 1757, 'n_words': 435}