GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |
GeezerVison is showing doc.wikimedia.org — MediaWiki: includes/libs/FileBackend/FSFile/FSFile.php Source File
Toggle main menu visibility
FSFile.php
Go to the documentation of this file.
1<?php
9
11
12use Wikimedia\Timestamp\ConvertibleTimestamp;
13use Wikimedia\Timestamp\TimestampFormat as TS;
14
23
26
35
44
53
60 // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
61 return @filesize( $this->path );
62 }
63
70 // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
71 $timestamp = @filemtime( $this->path );
72 if ( $timestamp !== false ) {
73 $timestamp = ConvertibleTimestamp::convert( TS::MW, $timestamp );
74 }
75
76 return $timestamp;
77 }
78
97 $info = self::placeholderProps();
99
100 if ( $info['fileExists'] ) {
103
104 $mime = mime_content_type( $this->path );
105 # MIME type according to file contents
106 $info['file-mime'] = ( $mime === false ) ? 'unknown/unknown' : $mime;
107 # logical MIME type
108 $info['mime'] = $mime;
109
110 if ( str_contains( $mime, '/' ) ) {
111 [ $info['major_mime'], $info['minor_mime'] ] = explode( '/', $mime, 2 );
112 } else {
113 [ $info['major_mime'], $info['minor_mime'] ] = [ $mime, 'unknown' ];
114 }
115 }
116
117 return $info;
118 }
119
135 return [
136 'fileExists' => false,
137 'size' => 0,
138 'file-mime' => null,
139 'major_mime' => null,
140 'minor_mime' => null,
141 'mime' => null,
142 'sha1' => '',
143 ];
144 }
145
157 if ( $this->sha1Base36 !== null && !$recache ) {
159 }
160
161 // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
162 $this->sha1Base36 = @sha1_file( $this->path );
163
164 if ( $this->sha1Base36 !== false ) {
165 $this->sha1Base36 = \Wikimedia\base_convert( $this->sha1Base36, 16, 36, 31 );
166 }
167
169 }
170
180
182
184 }
185
196
197 return $fsFile->getProps( $ext );
198 }
199
212
213 return $fsFile->getSha1Base36();
214 }
215}
216
218class_alias( FSFile::class, 'FSFile' );
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2) Logs a warning that a deprecated feature was used. Definition GlobalFunctions.php:463 Class representing a non-directory file on the file system. Definition FSFile.php:20 getSha1Base36( $recache=false) Get a SHA-1 hash of a file in the local filesystem, in base-36 lower case encoding,... Definition FSFile.php:156 static getPropsFromPath( $path, $ext=true) Get an associative array containing information about a file in the local filesystem. Definition FSFile.php:194 static getSha1Base36FromPath( $path) Get a SHA-1 hash of a file in the local filesystem, in base-36 lower case encoding,... Definition FSFile.php:210 static extensionFromPath( $path) Get the final file extension from a file system path. Definition FSFile.php:178 getProps( $ext=true) Get an associative array containing information about a file with the given storage path. Definition FSFile.php:96 static placeholderProps() Placeholder file properties to use for files that don't exist. Definition FSFile.php:134 Definition FSFile.php:10
| |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |