+ $status->success[$i] = $good;
+ }
+ return $status;
+ }
+
+ /**
+ * Deletes a batch of files. Each file can be a (zone, rel) pairs, a
+ * virtual url or a real path. It will try to delete each file, but
+ * ignores any errors that may occur
+ *
+ * @param $pairs array List of files to delete
+ */
+ function cleanupBatch( $files ) {
+ foreach ( $files as $file ) {
+ if ( is_array( $file ) ) {
+ // This is a pair, extract it
+ list( $zone, $rel ) = $file;
+ $root = $this->getZonePath( $zone );
+ $path = "$root/$rel";
+ } else {
+ if ( self::isVirtualUrl( $file ) ) {
+ // This is a virtual url, resolve it
+ $path = $this->resolveVirtualUrl( $file );
+ } else {
+ // This is a full file name
+ $path = $file;
+ }
+ }
+
+ wfSuppressWarnings();
+ unlink( $path );
+ wfRestoreWarnings();
+ }
+ }
+
+ function append( $srcPath, $toAppendPath, $flags = 0 ) {
+ $status = $this->newGood();
+
+ // Resolve the virtual URL
+ if ( self::isVirtualUrl( $toAppendPath ) ) {
+ $toAppendPath = $this->resolveVirtualUrl( $toAppendPath );
+ }
+ // Make sure the files are there
+ if ( !is_file( $toAppendPath ) )
+ $status->fatal( 'filenotfound', $toAppendPath );
+
+ if ( !is_file( $srcPath ) )
+ $status->fatal( 'filenotfound', $srcPath );
+
+ if ( !$status->isOk() ) return $status;
+
+ // Do the append
+ $chunk = file_get_contents( $srcPath );
+ if( $chunk === false ) {
+ $status->fatal( 'fileappenderrorread', $srcPath );
+ }
+
+ if( $status->isOk() ) {
+ if ( file_put_contents( $toAppendPath, $chunk, FILE_APPEND ) ) {
+ $status->value = $toAppendPath;
+ } else {
+ $status->fatal( 'fileappenderror', $srcPath, $toAppendPath);
+ }
+ }
+
+ if ( $flags & self::DELETE_SOURCE ) {
+ unlink( $srcPath );