Advertisement
Guest User

add-custom-params-addString.patch

a guest
Nov 8th, 2013
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 5.04 KB | None | 0 0
  1. diff -ur old/Archive_Tar-1.3.11/Archive/Tar.php new/Archive_Tar-1.3.11/Archive/Tar.php
  2. --- old/Archive_Tar-1.3.11/Archive/Tar.php      2013-02-09 03:44:17.000000000 -0800
  3. +++ new/Archive_Tar-1.3.11/Archive/Tar.php      2013-11-08 13:55:22.318276898 -0800
  4. @@ -409,12 +409,29 @@
  5.      *                           the archive.
  6.      * @param int    $p_datetime A custom date/time (unix timestamp)
  7.      *                           for the file (optional).
  8. +    * @param array  $p_params   An array of optional params:
  9. +    *                               stamp => the datetime (replaces
  10. +    *                                   datetime above if it exists)
  11. +    *                               mode => the permissions on the
  12. +    *                                   file (600 by default)
  13. +    *                               type => is this a link?  See the
  14. +    *                                   tar specification for details.
  15. +    *                                   (default = regular file)
  16. +    *                               uid => the user ID of the file
  17. +    *                                   (default = 0 = root)
  18. +    *                               gid => the group ID of the file
  19. +    *                                   (default = 0 = root)
  20.      *
  21.      * @return true on success, false on error.
  22.      * @access public
  23.      */
  24. -    function addString($p_filename, $p_string, $p_datetime = false)
  25. +    function addString($p_filename, $p_string, $p_datetime = false, $p_params = array())
  26.      {
  27. +        $p_stamp = @$p_params["stamp"] ? $p_params["stamp"] : ($p_datetime ? $p_datetime : time());
  28. +        $p_mode = @$p_params["mode"] ? $p_params["mode"] : 0600;
  29. +        $p_type = @$p_params["type"] ? $p_params["type"] : "";
  30. +        $p_uid = @$p_params["uid"] ? $p_params["uid"] : "";
  31. +        $p_gid = @$p_params["gid"] ? $p_params["gid"] : "";
  32.          $v_result = true;
  33.  
  34.          if (!$this->_isArchive()) {
  35. @@ -428,7 +445,7 @@
  36.              return false;
  37.  
  38.          // Need to check the get back to the temporary file ? ....
  39. -        $v_result = $this->_addString($p_filename, $p_string, $p_datetime);
  40. +        $v_result = $this->_addString($p_filename, $p_string, $p_datetime, $p_params);
  41.  
  42.          $this->_writeFooter();
  43.  
  44. @@ -1052,8 +1069,13 @@
  45.      // }}}
  46.  
  47.      // {{{ _addString()
  48. -    function _addString($p_filename, $p_string, $p_datetime = false)
  49. +    function _addString($p_filename, $p_string, $p_datetime = false, $p_params = array())
  50.      {
  51. +      $p_stamp = @$p_params["stamp"] ? $p_params["stamp"] : ($p_datetime ? $p_datetime : time());
  52. +      $p_mode = @$p_params["mode"] ? $p_params["mode"] : 0600;
  53. +      $p_type = @$p_params["type"] ? $p_params["type"] : "";
  54. +      $p_uid = @$p_params["uid"] ? $p_params["uid"] : 0;
  55. +      $p_gid = @$p_params["gid"] ? $p_params["gid"] : 0;
  56.        if (!$this->_file) {
  57.            $this->_error('Invalid file descriptor');
  58.            return false;
  59. @@ -1073,7 +1095,7 @@
  60.        }
  61.  
  62.        if (!$this->_writeHeaderBlock($p_filename, strlen($p_string),
  63. -                                    $p_datetime, 384, "", 0, 0))
  64. +                                    $p_stamp, $p_mode, $p_type, $p_uid, $p_gid))
  65.            return false;
  66.  
  67.        $i=0;
  68. diff -ur old/Archive_Tar-1.3.11/docs/Archive_Tar.txt new/Archive_Tar-1.3.11/docs/Archive_Tar.txt
  69. --- old/Archive_Tar-1.3.11/docs/Archive_Tar.txt 2013-02-09 03:44:17.000000000 -0800
  70. +++ new/Archive_Tar-1.3.11/docs/Archive_Tar.txt 2013-11-08 14:02:11.058267284 -0800
  71. @@ -293,7 +293,7 @@
  72.  How it works :
  73.    Simply call the addModify() method with the right parameters.
  74.  
  75. -Method : addString($p_filename, $p_string)
  76. +Method : addString($p_filename, $p_string, $p_datetime, $p_params)
  77.  Description :
  78.    This method add a single string as a file at the
  79.    end of the existing archive. If the archive does not yet exists it
  80. @@ -302,12 +302,26 @@
  81.    $p_filename : A string which contains the full filename path
  82.                  that will be associated with the string.
  83.    $p_string :   The content of the file added in the archive.
  84. +  $p_datetime : (Optional) Timestamp of the file (default = now)
  85. +  $p_params :   (Optional) Various file metadata:
  86. +                    stamp - As above, timestamp of the file
  87. +                    mode - UNIX-style permissions (default 0600)
  88. +                    type - Is this a regular file or link (see TAR
  89. +                           format spec for how to create a hard/symlink)
  90. +                    uid - UNIX-style user ID (default 0 = root)
  91. +                    gid - UNIX-style group ID (default 0 = root)
  92.  Return value :
  93.    true on success, false on error.
  94.  Sample 1 :
  95.    $v_archive = & new Archive_Tar($p_filename);
  96.    $v_archive->setErrorHandling(PEAR_ERROR_PRINT);
  97.    $v_result = $v_archive->addString('data/test.txt', 'This is the text of the string');
  98. +  $v_result = $v_archive->addString(
  99. +                  'data/test.sh',
  100. +                  "#!/bin/sh\necho 'Hello'",
  101. +                  time(),
  102. +                  array( "mode" => 0755, "uid" => 34 )
  103. +              );
  104.  
  105.  
  106.  Method : extract($p_path = "")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement