From: skodak Date: Wed, 20 May 2009 21:27:56 +0000 (+0000) Subject: MDL-18111 improving file api comments and docs, fixing license header X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=16a95e8f8dce36968d8bc014696da29d6e4dc872;p=moodle.git MDL-18111 improving file api comments and docs, fixing license header --- diff --git a/lib/file/stored_file.php b/lib/file/stored_file.php index d3e1afe241..85691fd4c5 100644 --- a/lib/file/stored_file.php +++ b/lib/file/stored_file.php @@ -1,4 +1,30 @@ -. + + +/** + * Class representing filesin Moodle file storage. + * + * @package moodle-core + * @copyright 2008 Petr Skoda (http://skodak.org) + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +require_once("$CFG->libdir/file/stored_file.php"); /** * Class representing local files stored in sha1 file pool @@ -223,58 +249,115 @@ class stored_file { return $this->fs->create_directory($this->file_record->contextid, $this->file_record->filearea, $this->file_record->itemid, $filepath); } + /** + * Returns context id of the file + * @return int context id + */ public function get_contextid() { return $this->file_record->contextid; } + /** + * Returns file area name, the areas do not have to be unique, + * but usually have form pluginname_typeofarea such as forum_attachments + * @return string + */ public function get_filearea() { return $this->file_record->filearea; } + /** + * Returns returns item id of file + * @return int + */ public function get_itemid() { return $this->file_record->itemid; } + /** + * Returns file path - starts and ends with /, \ are not allowed. + * @return string + */ public function get_filepath() { return $this->file_record->filepath; } + /** + * Returns file name or '.' in case of directories. + * @return string + */ public function get_filename() { return $this->file_record->filename; } + /** + * Returns id of user who created the file. + * @return int + */ public function get_userid() { return $this->file_record->userid; } + /** + * Returns the size of file in bytes. + * @return int bytes + */ public function get_filesize() { return $this->file_record->filesize; } + /** + * Returns mime type of file + * @return string + */ public function get_mimetype() { return $this->file_record->mimetype; } + /** + * Returns unix timestamp of file creation date + * @return int + */ public function get_timecreated() { return $this->file_record->timecreated; } + /** + * Returns unix timestamp of last file modification + * @return int + */ public function get_timemodified() { return $this->file_record->timemodified; } + /** + * Returns file status flag + * @return int 0 means file OK, anything else is a problem and file can not be used + */ public function get_status() { return $this->file_record->status; } + /** + * Returns file id + * @return int + */ public function get_id() { return $this->file_record->id; } + /** + * Returns sha1 hash of file content + * @return string + */ public function get_contenthash() { return $this->file_record->contenthash; } + /** + * Returns sha1 hash of all file path components sha1(contextid/filearea/itemid/dir/dir/filename.ext) + * @return string + */ public function get_pathnamehash() { return $this->file_record->pathnamehash; }