Projet

Général

Profil

Révision c9e51f47

Ajouté par Julien Enselme il y a environ 7 ans

Udpate to 7.54

Voir les différences:

drupal7/includes/stream_wrappers.inc
133 133
   * @param $uri
134 134
   *   A string containing the URI that should be used for this instance.
135 135
   */
136
  function setUri($uri);
136
  public function setUri($uri);
137 137

  
138 138
  /**
139 139
   * Returns the stream resource URI.
......
219 219
  public function dirname($uri = NULL);
220 220
}
221 221

  
222

  
223 222
/**
224 223
 * Drupal stream wrapper base class for local files.
225 224
 *
......
549 548
    return fclose($this->handle);
550 549
  }
551 550

  
551
  /**
552
   * Sets metadata on the stream.
553
   *
554
   * WARNING: Do not call this method directly! It will be called internally by
555
   * PHP itself when one of the following functions is called on a stream URL:
556
   *
557
   * @param string $uri
558
   *   A string containing the URI to the file to set metadata on.
559
   * @param int $option
560
   *   One of:
561
   *   - STREAM_META_TOUCH: The method was called in response to touch().
562
   *   - STREAM_META_OWNER_NAME: The method was called in response to chown()
563
   *     with string parameter.
564
   *   - STREAM_META_OWNER: The method was called in response to chown().
565
   *   - STREAM_META_GROUP_NAME: The method was called in response to chgrp().
566
   *   - STREAM_META_GROUP: The method was called in response to chgrp().
567
   *   - STREAM_META_ACCESS: The method was called in response to chmod().
568
   * @param mixed $value
569
   *   If option is:
570
   *   - STREAM_META_TOUCH: Array consisting of two arguments of the touch()
571
   *     function.
572
   *   - STREAM_META_OWNER_NAME or STREAM_META_GROUP_NAME: The name of the owner
573
   *     user/group as string.
574
   *   - STREAM_META_OWNER or STREAM_META_GROUP: The value of the owner
575
   *     user/group as integer.
576
   *   - STREAM_META_ACCESS: The argument of the chmod() as integer.
577
   *
578
   * @return bool
579
   *   Returns TRUE on success or FALSE on failure. If $option is not
580
   *   implemented, FALSE should be returned.
581
   *
582
   * @see touch()
583
   * @see chmod()
584
   * @see chown()
585
   * @see chgrp()
586
   * @link http://php.net/manual/streamwrapper.stream-metadata.php
587
   */
588
  public function stream_metadata($uri, $option, $value) {
589
    $target = $this->getLocalPath($uri);
590
    $return = FALSE;
591
    switch ($option) {
592
      case STREAM_META_TOUCH:
593
        if (!empty($value)) {
594
          $return = touch($target, $value[0], $value[1]);
595
        }
596
        else {
597
          $return = touch($target);
598
        }
599
        break;
600

  
601
      case STREAM_META_OWNER_NAME:
602
      case STREAM_META_OWNER:
603
        $return = chown($target, $value);
604
        break;
605

  
606
      case STREAM_META_GROUP_NAME:
607
      case STREAM_META_GROUP:
608
        $return = chgrp($target, $value);
609
        break;
610

  
611
      case STREAM_META_ACCESS:
612
        $return = chmod($target, $value);
613
        break;
614
    }
615
    if ($return) {
616
      // For convenience clear the file status cache of the underlying file,
617
      // since metadata operations are often followed by file status checks.
618
      clearstatcache(TRUE, $target);
619
    }
620
    return $return;
621
  }
622

  
623
  /**
624
   * Truncate stream.
625
   *
626
   * Will respond to truncation; e.g., through ftruncate().
627
   *
628
   * @param int $new_size
629
   *   The new size.
630
   *
631
   * @return bool
632
   *   TRUE on success, FALSE otherwise.
633
   */
634
  public function stream_truncate($new_size) {
635
    return ftruncate($this->handle, $new_size);
636
  }
637

  
638
  /**
639
   * Retrieve the underlying stream resource.
640
   *
641
   * This method is called in response to stream_select().
642
   *
643
   * @param int $cast_as
644
   *   Can be STREAM_CAST_FOR_SELECT when stream_select() is calling
645
   *   stream_cast() or STREAM_CAST_AS_STREAM when stream_cast() is called for
646
   *   other uses.
647
   *
648
   * @return resource|false
649
   *   The underlying stream resource or FALSE if stream_select() is not
650
   *   supported.
651
   *
652
   * @see stream_select()
653
   * @link http://php.net/manual/streamwrapper.stream-cast.php
654
   */
655
  public function stream_cast($cast_as) {
656
    return $this->handle ? $this->handle : FALSE;
657
  }
658

  
659
  /**
660
   * Change stream options.
661
   *
662
   * This method is called to set options on the stream.
663
   *
664
   * Since Windows systems do not allow it and it is not needed for most use
665
   * cases anyway, this method is not supported on local files and will trigger
666
   * an error and return false. If needed, custom subclasses can provide
667
   * OS-specific implementations for advanced use cases.
668
   *
669
   * @param int $option
670
   *   One of:
671
   *   - STREAM_OPTION_BLOCKING: The method was called in response to
672
   *     stream_set_blocking().
673
   *   - STREAM_OPTION_READ_TIMEOUT: The method was called in response to
674
   *     stream_set_timeout().
675
   *   - STREAM_OPTION_WRITE_BUFFER: The method was called in response to
676
   *     stream_set_write_buffer().
677
   * @param int $arg1
678
   *   If option is:
679
   *   - STREAM_OPTION_BLOCKING: The requested blocking mode:
680
   *     - 1 means blocking.
681
   *     - 0 means not blocking.
682
   *   - STREAM_OPTION_READ_TIMEOUT: The timeout in seconds.
683
   *   - STREAM_OPTION_WRITE_BUFFER: The buffer mode, STREAM_BUFFER_NONE or
684
   *     STREAM_BUFFER_FULL.
685
   * @param int $arg2
686
   *   If option is:
687
   *   - STREAM_OPTION_BLOCKING: This option is not set.
688
   *   - STREAM_OPTION_READ_TIMEOUT: The timeout in microseconds.
689
   *   - STREAM_OPTION_WRITE_BUFFER: The requested buffer size.
690
   *
691
   * @return bool
692
   *   TRUE on success, FALSE otherwise. If $option is not implemented, FALSE
693
   *   should be returned.
694
   */
695
  public function stream_set_option($option, $arg1, $arg2) {
696
    trigger_error('stream_set_option() not supported for local file based stream wrappers', E_USER_WARNING);
697
    return FALSE;
698
  }
699

  
552 700
  /**
553 701
   * Support for unlink().
554 702
   *

Formats disponibles : Unified diff