Index: trunk/extensions/Deployment/includes/filesystems/FtpFilesystem.php |
— | — | @@ -110,7 +110,7 @@ |
111 | 111 | * @see Filesystem::changeDir |
112 | 112 | */ |
113 | 113 | public function changeDir( $dir ) { |
114 | | - return @ftp_chdir( $this->connection, $dir ); |
| 114 | + return (bool)@ftp_chdir( $this->connection, $dir ); |
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
— | — | @@ -124,7 +124,38 @@ |
125 | 125 | * @see Filesystem::chmod |
126 | 126 | */ |
127 | 127 | public function chmod( $file, $mode = false, $recursive = false ) { |
| 128 | + // TODO: refactor up? |
| 129 | + if ( !$mode ) { |
| 130 | + if ( $this->isFile( $file ) ) { |
| 131 | + $mode = FS_CHMOD_FILE; |
| 132 | + } |
| 133 | + elseif ( $this->isDir( $file ) ) { |
| 134 | + $mode = FS_CHMOD_DIR; |
| 135 | + } |
| 136 | + else { |
| 137 | + return false; |
| 138 | + } |
| 139 | + } |
| 140 | + |
| 141 | + // Not recursive, so just use chmod. |
| 142 | + if ( !$recursive || !$this->isDir( $file ) ) { |
| 143 | + if ( !function_exists( 'ftp_chmod' ) ) { |
| 144 | + return (bool)@ftp_site( $this->connection, sprintf( 'CHMOD %o %s', $mode, $file ) ); |
| 145 | + } |
| 146 | + else { |
| 147 | + return (bool)@ftp_chmod( $this->connection, $mode, $file ); |
| 148 | + } |
| 149 | + } |
| 150 | + |
| 151 | + // Recursive approach required. |
| 152 | + $file = rtrim( $file, '/' ) . '/'; |
| 153 | + $files = $this->listDir( $file ); |
128 | 154 | |
| 155 | + foreach ( $files as $fileName ) { |
| 156 | + $this->chmod( $file . $fileName, $mode, $recursive ); |
| 157 | + } |
| 158 | + |
| 159 | + return true; |
129 | 160 | } |
130 | 161 | |
131 | 162 | /** |
Index: trunk/extensions/Deployment/includes/filesystems/DirectFilesystem.php |
— | — | @@ -35,7 +35,7 @@ |
36 | 36 | * @see Filesystem::changeDir |
37 | 37 | */ |
38 | 38 | public function changeDir( $dir ) { |
39 | | - return @chdir( $dir ); |
| 39 | + return (bool)@chdir( $dir ); |
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
— | — | @@ -47,7 +47,7 @@ |
48 | 48 | } |
49 | 49 | |
50 | 50 | // Not recursive, so just use chgrp. |
51 | | - if ( !$recursive || !$this->is_dir($file) ) { |
| 51 | + if ( !$recursive || !$this->isDir( $file ) ) { |
52 | 52 | return @chgrp( $file, $group ); |
53 | 53 | } |
54 | 54 | |
— | — | @@ -66,7 +66,33 @@ |
67 | 67 | * @see Filesystem::chmod |
68 | 68 | */ |
69 | 69 | public function chmod( $file, $mode = false, $recursive = false ) { |
| 70 | + // TODO: refactor up? |
| 71 | + if ( !$mode ) { |
| 72 | + if ( $this->isFile( $file ) ) { |
| 73 | + $mode = FS_CHMOD_FILE; |
| 74 | + } |
| 75 | + elseif ( $this->isDir( $file ) ) { |
| 76 | + $mode = FS_CHMOD_DIR; |
| 77 | + } |
| 78 | + else { |
| 79 | + return false; |
| 80 | + } |
| 81 | + } |
| 82 | + |
| 83 | + // Not recursive, so just use chmod. |
| 84 | + if ( !$recursive || !$this->isDir( $file ) ) { |
| 85 | + return (bool)@chmod( $file, $mode ); |
| 86 | + } |
| 87 | + |
| 88 | + // Recursive approach required. |
| 89 | + $file = rtrim( $file, '/' ) . '/'; |
| 90 | + $files = $this->listDir( $file ); |
70 | 91 | |
| 92 | + foreach ( $files as $fileName ) { |
| 93 | + $this->chmod( $file . $fileName, $mode, $recursive ); |
| 94 | + } |
| 95 | + |
| 96 | + return true; |
71 | 97 | } |
72 | 98 | |
73 | 99 | /** |
Index: trunk/extensions/Deployment/includes/Filesystem.php |
— | — | @@ -17,6 +17,9 @@ |
18 | 18 | * @defgroup Filesystem Filesystem |
19 | 19 | */ |
20 | 20 | |
| 21 | +define('FS_CHMOD_DIR', 0755 ); |
| 22 | +define('FS_CHMOD_FILE', 0644 ); |
| 23 | + |
21 | 24 | /** |
22 | 25 | * Base class providing a way to access filesystems. |
23 | 26 | * |