24 use Wikimedia\AtEase\AtEase;
25 use Wikimedia\Timestamp\ConvertibleTimestamp;
63 return is_file( $this->path );
72 AtEase::suppressWarnings();
73 $size = filesize( $this->path );
74 AtEase::restoreWarnings();
85 AtEase::suppressWarnings();
86 $timestamp = filemtime( $this->path );
87 AtEase::restoreWarnings();
88 if ( $timestamp !==
false ) {
89 $timestamp = ConvertibleTimestamp::convert( TS_MW, $timestamp );
114 $info[
'fileExists'] = $this->
exists();
116 if ( $info[
'fileExists'] ) {
117 $info[
'size'] = $this->
getSize();
120 $mime = mime_content_type( $this->path );
121 # MIME type according to file contents
122 $info[
'file-mime'] = ( $mime === false ) ?
'unknown/unknown' : $mime;
124 $info[
'mime'] = $mime;
126 if ( strpos( $mime,
'/' ) !== false ) {
127 list( $info[
'major_mime'], $info[
'minor_mime'] ) = explode(
'/', $mime, 2 );
129 list( $info[
'major_mime'], $info[
'minor_mime'] ) = [ $mime,
'unknown' ];
152 $info[
'fileExists'] =
false;
154 $info[
'file-mime'] =
null;
155 $info[
'major_mime'] =
null;
156 $info[
'minor_mime'] =
null;
157 $info[
'mime'] =
null;
174 if ( $this->sha1Base36 !==
null && !$recache ) {
178 AtEase::suppressWarnings();
179 $this->sha1Base36 = sha1_file( $this->path );
180 AtEase::restoreWarnings();
182 if ( $this->sha1Base36 !==
false ) {
183 $this->sha1Base36 = Wikimedia\base_convert( $this->sha1Base36, 16, 36, 31 );
196 $i = strrpos(
$path,
'.' );
198 return strtolower( $i ? substr(
$path, $i + 1 ) :
'' );
210 $fsFile =
new self(
$path );
212 return $fsFile->getProps(
$ext );
226 $fsFile =
new self(
$path );
228 return $fsFile->getSha1Base36();